github.com/twilio/twilio-go@v1.20.1/rest/api/v2010/accounts_conferences_participants.go (about) 1 /* 2 * This code was generated by 3 * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ 4 * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ 5 * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ 6 * 7 * Twilio - Api 8 * This is the public Twilio REST API. 9 * 10 * NOTE: This class is auto generated by OpenAPI Generator. 11 * https://openapi-generator.tech 12 * Do not edit the class manually. 13 */ 14 15 package openapi 16 17 import ( 18 "encoding/json" 19 "fmt" 20 "net/url" 21 "strings" 22 23 "github.com/twilio/twilio-go/client" 24 ) 25 26 // Optional parameters for the method 'CreateParticipant' 27 type CreateParticipantParams struct { 28 // The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that will create the resource. 29 PathAccountSid *string `json:"PathAccountSid,omitempty"` 30 // 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. 31 From *string `json:"From,omitempty"` 32 // 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. 33 To *string `json:"To,omitempty"` 34 // The URL we should call using the `status_callback_method` to send status information to your application. 35 StatusCallback *string `json:"StatusCallback,omitempty"` 36 // The HTTP method we should use to call `status_callback`. Can be: `GET` and `POST` and defaults to `POST`. 37 StatusCallbackMethod *string `json:"StatusCallbackMethod,omitempty"` 38 // 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`. 39 StatusCallbackEvent *[]string `json:"StatusCallbackEvent,omitempty"` 40 // A label for this participant. If one is supplied, it may subsequently be used to fetch, update or delete the participant. 41 Label *string `json:"Label,omitempty"` 42 // 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. 43 Timeout *int `json:"Timeout,omitempty"` 44 // Whether to record the participant and their conferences, including the time between conferences. Can be `true` or `false` and the default is `false`. 45 Record *bool `json:"Record,omitempty"` 46 // Whether the agent is muted in the conference. Can be `true` or `false` and the default is `false`. 47 Muted *bool `json:"Muted,omitempty"` 48 // 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`. 49 Beep *string `json:"Beep,omitempty"` 50 // 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. 51 StartConferenceOnEnter *bool `json:"StartConferenceOnEnter,omitempty"` 52 // Whether to end the conference when the participant leaves. Can be: `true` or `false` and defaults to `false`. 53 EndConferenceOnExit *bool `json:"EndConferenceOnExit,omitempty"` 54 // 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). 55 WaitUrl *string `json:"WaitUrl,omitempty"` 56 // 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. 57 WaitMethod *string `json:"WaitMethod,omitempty"` 58 // 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`. 59 EarlyMedia *bool `json:"EarlyMedia,omitempty"` 60 // The maximum number of participants in the conference. Can be a positive integer from `2` to `250`. The default value is `250`. 61 MaxParticipants *int `json:"MaxParticipants,omitempty"` 62 // 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`. 63 ConferenceRecord *string `json:"ConferenceRecord,omitempty"` 64 // Whether to trim leading and trailing silence from the conference recording. Can be: `trim-silence` or `do-not-trim` and defaults to `trim-silence`. 65 ConferenceTrim *string `json:"ConferenceTrim,omitempty"` 66 // 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. 67 ConferenceStatusCallback *string `json:"ConferenceStatusCallback,omitempty"` 68 // The HTTP method we should use to call `conference_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. 69 ConferenceStatusCallbackMethod *string `json:"ConferenceStatusCallbackMethod,omitempty"` 70 // 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`. 71 ConferenceStatusCallbackEvent *[]string `json:"ConferenceStatusCallbackEvent,omitempty"` 72 // The recording channels for the final recording. Can be: `mono` or `dual` and the default is `mono`. 73 RecordingChannels *string `json:"RecordingChannels,omitempty"` 74 // The URL that we should call using the `recording_status_callback_method` when the recording status changes. 75 RecordingStatusCallback *string `json:"RecordingStatusCallback,omitempty"` 76 // The HTTP method we should use when we call `recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. 77 RecordingStatusCallbackMethod *string `json:"RecordingStatusCallbackMethod,omitempty"` 78 // The SIP username used for authentication. 79 SipAuthUsername *string `json:"SipAuthUsername,omitempty"` 80 // The SIP password for authentication. 81 SipAuthPassword *string `json:"SipAuthPassword,omitempty"` 82 // 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`. 83 Region *string `json:"Region,omitempty"` 84 // The URL we should call using the `conference_recording_status_callback_method` when the conference recording is available. 85 ConferenceRecordingStatusCallback *string `json:"ConferenceRecordingStatusCallback,omitempty"` 86 // The HTTP method we should use to call `conference_recording_status_callback`. Can be: `GET` or `POST` and defaults to `POST`. 87 ConferenceRecordingStatusCallbackMethod *string `json:"ConferenceRecordingStatusCallbackMethod,omitempty"` 88 // 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'`. 89 RecordingStatusCallbackEvent *[]string `json:"RecordingStatusCallbackEvent,omitempty"` 90 // 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'` 91 ConferenceRecordingStatusCallbackEvent *[]string `json:"ConferenceRecordingStatusCallbackEvent,omitempty"` 92 // 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. 93 Coaching *bool `json:"Coaching,omitempty"` 94 // 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`. 95 CallSidToCoach *string `json:"CallSidToCoach,omitempty"` 96 // 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`. 97 JitterBufferSize *string `json:"JitterBufferSize,omitempty"` 98 // 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) 99 Byoc *string `json:"Byoc,omitempty"` 100 // 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. 101 CallerId *string `json:"CallerId,omitempty"` 102 // 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) 103 CallReason *string `json:"CallReason,omitempty"` 104 // 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. 105 RecordingTrack *string `json:"RecordingTrack,omitempty"` 106 // The maximum duration of the call in seconds. Constraints depend on account and configuration. 107 TimeLimit *int `json:"TimeLimit,omitempty"` 108 // 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). 109 MachineDetection *string `json:"MachineDetection,omitempty"` 110 // 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. 111 MachineDetectionTimeout *int `json:"MachineDetectionTimeout,omitempty"` 112 // 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. 113 MachineDetectionSpeechThreshold *int `json:"MachineDetectionSpeechThreshold,omitempty"` 114 // The number of milliseconds of silence after speech activity at which point the speech activity is considered complete. Possible Values: 500-5000. Default: 1200. 115 MachineDetectionSpeechEndThreshold *int `json:"MachineDetectionSpeechEndThreshold,omitempty"` 116 // The number of milliseconds of initial silence after which an `unknown` AnsweredBy result will be returned. Possible Values: 2000-10000. Default: 5000. 117 MachineDetectionSilenceTimeout *int `json:"MachineDetectionSilenceTimeout,omitempty"` 118 // 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. 119 AmdStatusCallback *string `json:"AmdStatusCallback,omitempty"` 120 // The HTTP method we should use when calling the `amd_status_callback` URL. Can be: `GET` or `POST` and the default is `POST`. 121 AmdStatusCallbackMethod *string `json:"AmdStatusCallbackMethod,omitempty"` 122 // 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`. 123 Trim *string `json:"Trim,omitempty"` 124 // 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. 125 CallToken *string `json:"CallToken,omitempty"` 126 } 127 128 func (params *CreateParticipantParams) SetPathAccountSid(PathAccountSid string) *CreateParticipantParams { 129 params.PathAccountSid = &PathAccountSid 130 return params 131 } 132 func (params *CreateParticipantParams) SetFrom(From string) *CreateParticipantParams { 133 params.From = &From 134 return params 135 } 136 func (params *CreateParticipantParams) SetTo(To string) *CreateParticipantParams { 137 params.To = &To 138 return params 139 } 140 func (params *CreateParticipantParams) SetStatusCallback(StatusCallback string) *CreateParticipantParams { 141 params.StatusCallback = &StatusCallback 142 return params 143 } 144 func (params *CreateParticipantParams) SetStatusCallbackMethod(StatusCallbackMethod string) *CreateParticipantParams { 145 params.StatusCallbackMethod = &StatusCallbackMethod 146 return params 147 } 148 func (params *CreateParticipantParams) SetStatusCallbackEvent(StatusCallbackEvent []string) *CreateParticipantParams { 149 params.StatusCallbackEvent = &StatusCallbackEvent 150 return params 151 } 152 func (params *CreateParticipantParams) SetLabel(Label string) *CreateParticipantParams { 153 params.Label = &Label 154 return params 155 } 156 func (params *CreateParticipantParams) SetTimeout(Timeout int) *CreateParticipantParams { 157 params.Timeout = &Timeout 158 return params 159 } 160 func (params *CreateParticipantParams) SetRecord(Record bool) *CreateParticipantParams { 161 params.Record = &Record 162 return params 163 } 164 func (params *CreateParticipantParams) SetMuted(Muted bool) *CreateParticipantParams { 165 params.Muted = &Muted 166 return params 167 } 168 func (params *CreateParticipantParams) SetBeep(Beep string) *CreateParticipantParams { 169 params.Beep = &Beep 170 return params 171 } 172 func (params *CreateParticipantParams) SetStartConferenceOnEnter(StartConferenceOnEnter bool) *CreateParticipantParams { 173 params.StartConferenceOnEnter = &StartConferenceOnEnter 174 return params 175 } 176 func (params *CreateParticipantParams) SetEndConferenceOnExit(EndConferenceOnExit bool) *CreateParticipantParams { 177 params.EndConferenceOnExit = &EndConferenceOnExit 178 return params 179 } 180 func (params *CreateParticipantParams) SetWaitUrl(WaitUrl string) *CreateParticipantParams { 181 params.WaitUrl = &WaitUrl 182 return params 183 } 184 func (params *CreateParticipantParams) SetWaitMethod(WaitMethod string) *CreateParticipantParams { 185 params.WaitMethod = &WaitMethod 186 return params 187 } 188 func (params *CreateParticipantParams) SetEarlyMedia(EarlyMedia bool) *CreateParticipantParams { 189 params.EarlyMedia = &EarlyMedia 190 return params 191 } 192 func (params *CreateParticipantParams) SetMaxParticipants(MaxParticipants int) *CreateParticipantParams { 193 params.MaxParticipants = &MaxParticipants 194 return params 195 } 196 func (params *CreateParticipantParams) SetConferenceRecord(ConferenceRecord string) *CreateParticipantParams { 197 params.ConferenceRecord = &ConferenceRecord 198 return params 199 } 200 func (params *CreateParticipantParams) SetConferenceTrim(ConferenceTrim string) *CreateParticipantParams { 201 params.ConferenceTrim = &ConferenceTrim 202 return params 203 } 204 func (params *CreateParticipantParams) SetConferenceStatusCallback(ConferenceStatusCallback string) *CreateParticipantParams { 205 params.ConferenceStatusCallback = &ConferenceStatusCallback 206 return params 207 } 208 func (params *CreateParticipantParams) SetConferenceStatusCallbackMethod(ConferenceStatusCallbackMethod string) *CreateParticipantParams { 209 params.ConferenceStatusCallbackMethod = &ConferenceStatusCallbackMethod 210 return params 211 } 212 func (params *CreateParticipantParams) SetConferenceStatusCallbackEvent(ConferenceStatusCallbackEvent []string) *CreateParticipantParams { 213 params.ConferenceStatusCallbackEvent = &ConferenceStatusCallbackEvent 214 return params 215 } 216 func (params *CreateParticipantParams) SetRecordingChannels(RecordingChannels string) *CreateParticipantParams { 217 params.RecordingChannels = &RecordingChannels 218 return params 219 } 220 func (params *CreateParticipantParams) SetRecordingStatusCallback(RecordingStatusCallback string) *CreateParticipantParams { 221 params.RecordingStatusCallback = &RecordingStatusCallback 222 return params 223 } 224 func (params *CreateParticipantParams) SetRecordingStatusCallbackMethod(RecordingStatusCallbackMethod string) *CreateParticipantParams { 225 params.RecordingStatusCallbackMethod = &RecordingStatusCallbackMethod 226 return params 227 } 228 func (params *CreateParticipantParams) SetSipAuthUsername(SipAuthUsername string) *CreateParticipantParams { 229 params.SipAuthUsername = &SipAuthUsername 230 return params 231 } 232 func (params *CreateParticipantParams) SetSipAuthPassword(SipAuthPassword string) *CreateParticipantParams { 233 params.SipAuthPassword = &SipAuthPassword 234 return params 235 } 236 func (params *CreateParticipantParams) SetRegion(Region string) *CreateParticipantParams { 237 params.Region = &Region 238 return params 239 } 240 func (params *CreateParticipantParams) SetConferenceRecordingStatusCallback(ConferenceRecordingStatusCallback string) *CreateParticipantParams { 241 params.ConferenceRecordingStatusCallback = &ConferenceRecordingStatusCallback 242 return params 243 } 244 func (params *CreateParticipantParams) SetConferenceRecordingStatusCallbackMethod(ConferenceRecordingStatusCallbackMethod string) *CreateParticipantParams { 245 params.ConferenceRecordingStatusCallbackMethod = &ConferenceRecordingStatusCallbackMethod 246 return params 247 } 248 func (params *CreateParticipantParams) SetRecordingStatusCallbackEvent(RecordingStatusCallbackEvent []string) *CreateParticipantParams { 249 params.RecordingStatusCallbackEvent = &RecordingStatusCallbackEvent 250 return params 251 } 252 func (params *CreateParticipantParams) SetConferenceRecordingStatusCallbackEvent(ConferenceRecordingStatusCallbackEvent []string) *CreateParticipantParams { 253 params.ConferenceRecordingStatusCallbackEvent = &ConferenceRecordingStatusCallbackEvent 254 return params 255 } 256 func (params *CreateParticipantParams) SetCoaching(Coaching bool) *CreateParticipantParams { 257 params.Coaching = &Coaching 258 return params 259 } 260 func (params *CreateParticipantParams) SetCallSidToCoach(CallSidToCoach string) *CreateParticipantParams { 261 params.CallSidToCoach = &CallSidToCoach 262 return params 263 } 264 func (params *CreateParticipantParams) SetJitterBufferSize(JitterBufferSize string) *CreateParticipantParams { 265 params.JitterBufferSize = &JitterBufferSize 266 return params 267 } 268 func (params *CreateParticipantParams) SetByoc(Byoc string) *CreateParticipantParams { 269 params.Byoc = &Byoc 270 return params 271 } 272 func (params *CreateParticipantParams) SetCallerId(CallerId string) *CreateParticipantParams { 273 params.CallerId = &CallerId 274 return params 275 } 276 func (params *CreateParticipantParams) SetCallReason(CallReason string) *CreateParticipantParams { 277 params.CallReason = &CallReason 278 return params 279 } 280 func (params *CreateParticipantParams) SetRecordingTrack(RecordingTrack string) *CreateParticipantParams { 281 params.RecordingTrack = &RecordingTrack 282 return params 283 } 284 func (params *CreateParticipantParams) SetTimeLimit(TimeLimit int) *CreateParticipantParams { 285 params.TimeLimit = &TimeLimit 286 return params 287 } 288 func (params *CreateParticipantParams) SetMachineDetection(MachineDetection string) *CreateParticipantParams { 289 params.MachineDetection = &MachineDetection 290 return params 291 } 292 func (params *CreateParticipantParams) SetMachineDetectionTimeout(MachineDetectionTimeout int) *CreateParticipantParams { 293 params.MachineDetectionTimeout = &MachineDetectionTimeout 294 return params 295 } 296 func (params *CreateParticipantParams) SetMachineDetectionSpeechThreshold(MachineDetectionSpeechThreshold int) *CreateParticipantParams { 297 params.MachineDetectionSpeechThreshold = &MachineDetectionSpeechThreshold 298 return params 299 } 300 func (params *CreateParticipantParams) SetMachineDetectionSpeechEndThreshold(MachineDetectionSpeechEndThreshold int) *CreateParticipantParams { 301 params.MachineDetectionSpeechEndThreshold = &MachineDetectionSpeechEndThreshold 302 return params 303 } 304 func (params *CreateParticipantParams) SetMachineDetectionSilenceTimeout(MachineDetectionSilenceTimeout int) *CreateParticipantParams { 305 params.MachineDetectionSilenceTimeout = &MachineDetectionSilenceTimeout 306 return params 307 } 308 func (params *CreateParticipantParams) SetAmdStatusCallback(AmdStatusCallback string) *CreateParticipantParams { 309 params.AmdStatusCallback = &AmdStatusCallback 310 return params 311 } 312 func (params *CreateParticipantParams) SetAmdStatusCallbackMethod(AmdStatusCallbackMethod string) *CreateParticipantParams { 313 params.AmdStatusCallbackMethod = &AmdStatusCallbackMethod 314 return params 315 } 316 func (params *CreateParticipantParams) SetTrim(Trim string) *CreateParticipantParams { 317 params.Trim = &Trim 318 return params 319 } 320 func (params *CreateParticipantParams) SetCallToken(CallToken string) *CreateParticipantParams { 321 params.CallToken = &CallToken 322 return params 323 } 324 325 // 326 func (c *ApiService) CreateParticipant(ConferenceSid string, params *CreateParticipantParams) (*ApiV2010Participant, error) { 327 path := "/2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants.json" 328 if params != nil && params.PathAccountSid != nil { 329 path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1) 330 } else { 331 path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1) 332 } 333 path = strings.Replace(path, "{"+"ConferenceSid"+"}", ConferenceSid, -1) 334 335 data := url.Values{} 336 headers := make(map[string]interface{}) 337 338 if params != nil && params.From != nil { 339 data.Set("From", *params.From) 340 } 341 if params != nil && params.To != nil { 342 data.Set("To", *params.To) 343 } 344 if params != nil && params.StatusCallback != nil { 345 data.Set("StatusCallback", *params.StatusCallback) 346 } 347 if params != nil && params.StatusCallbackMethod != nil { 348 data.Set("StatusCallbackMethod", *params.StatusCallbackMethod) 349 } 350 if params != nil && params.StatusCallbackEvent != nil { 351 for _, item := range *params.StatusCallbackEvent { 352 data.Add("StatusCallbackEvent", item) 353 } 354 } 355 if params != nil && params.Label != nil { 356 data.Set("Label", *params.Label) 357 } 358 if params != nil && params.Timeout != nil { 359 data.Set("Timeout", fmt.Sprint(*params.Timeout)) 360 } 361 if params != nil && params.Record != nil { 362 data.Set("Record", fmt.Sprint(*params.Record)) 363 } 364 if params != nil && params.Muted != nil { 365 data.Set("Muted", fmt.Sprint(*params.Muted)) 366 } 367 if params != nil && params.Beep != nil { 368 data.Set("Beep", *params.Beep) 369 } 370 if params != nil && params.StartConferenceOnEnter != nil { 371 data.Set("StartConferenceOnEnter", fmt.Sprint(*params.StartConferenceOnEnter)) 372 } 373 if params != nil && params.EndConferenceOnExit != nil { 374 data.Set("EndConferenceOnExit", fmt.Sprint(*params.EndConferenceOnExit)) 375 } 376 if params != nil && params.WaitUrl != nil { 377 data.Set("WaitUrl", *params.WaitUrl) 378 } 379 if params != nil && params.WaitMethod != nil { 380 data.Set("WaitMethod", *params.WaitMethod) 381 } 382 if params != nil && params.EarlyMedia != nil { 383 data.Set("EarlyMedia", fmt.Sprint(*params.EarlyMedia)) 384 } 385 if params != nil && params.MaxParticipants != nil { 386 data.Set("MaxParticipants", fmt.Sprint(*params.MaxParticipants)) 387 } 388 if params != nil && params.ConferenceRecord != nil { 389 data.Set("ConferenceRecord", *params.ConferenceRecord) 390 } 391 if params != nil && params.ConferenceTrim != nil { 392 data.Set("ConferenceTrim", *params.ConferenceTrim) 393 } 394 if params != nil && params.ConferenceStatusCallback != nil { 395 data.Set("ConferenceStatusCallback", *params.ConferenceStatusCallback) 396 } 397 if params != nil && params.ConferenceStatusCallbackMethod != nil { 398 data.Set("ConferenceStatusCallbackMethod", *params.ConferenceStatusCallbackMethod) 399 } 400 if params != nil && params.ConferenceStatusCallbackEvent != nil { 401 for _, item := range *params.ConferenceStatusCallbackEvent { 402 data.Add("ConferenceStatusCallbackEvent", item) 403 } 404 } 405 if params != nil && params.RecordingChannels != nil { 406 data.Set("RecordingChannels", *params.RecordingChannels) 407 } 408 if params != nil && params.RecordingStatusCallback != nil { 409 data.Set("RecordingStatusCallback", *params.RecordingStatusCallback) 410 } 411 if params != nil && params.RecordingStatusCallbackMethod != nil { 412 data.Set("RecordingStatusCallbackMethod", *params.RecordingStatusCallbackMethod) 413 } 414 if params != nil && params.SipAuthUsername != nil { 415 data.Set("SipAuthUsername", *params.SipAuthUsername) 416 } 417 if params != nil && params.SipAuthPassword != nil { 418 data.Set("SipAuthPassword", *params.SipAuthPassword) 419 } 420 if params != nil && params.Region != nil { 421 data.Set("Region", *params.Region) 422 } 423 if params != nil && params.ConferenceRecordingStatusCallback != nil { 424 data.Set("ConferenceRecordingStatusCallback", *params.ConferenceRecordingStatusCallback) 425 } 426 if params != nil && params.ConferenceRecordingStatusCallbackMethod != nil { 427 data.Set("ConferenceRecordingStatusCallbackMethod", *params.ConferenceRecordingStatusCallbackMethod) 428 } 429 if params != nil && params.RecordingStatusCallbackEvent != nil { 430 for _, item := range *params.RecordingStatusCallbackEvent { 431 data.Add("RecordingStatusCallbackEvent", item) 432 } 433 } 434 if params != nil && params.ConferenceRecordingStatusCallbackEvent != nil { 435 for _, item := range *params.ConferenceRecordingStatusCallbackEvent { 436 data.Add("ConferenceRecordingStatusCallbackEvent", item) 437 } 438 } 439 if params != nil && params.Coaching != nil { 440 data.Set("Coaching", fmt.Sprint(*params.Coaching)) 441 } 442 if params != nil && params.CallSidToCoach != nil { 443 data.Set("CallSidToCoach", *params.CallSidToCoach) 444 } 445 if params != nil && params.JitterBufferSize != nil { 446 data.Set("JitterBufferSize", *params.JitterBufferSize) 447 } 448 if params != nil && params.Byoc != nil { 449 data.Set("Byoc", *params.Byoc) 450 } 451 if params != nil && params.CallerId != nil { 452 data.Set("CallerId", *params.CallerId) 453 } 454 if params != nil && params.CallReason != nil { 455 data.Set("CallReason", *params.CallReason) 456 } 457 if params != nil && params.RecordingTrack != nil { 458 data.Set("RecordingTrack", *params.RecordingTrack) 459 } 460 if params != nil && params.TimeLimit != nil { 461 data.Set("TimeLimit", fmt.Sprint(*params.TimeLimit)) 462 } 463 if params != nil && params.MachineDetection != nil { 464 data.Set("MachineDetection", *params.MachineDetection) 465 } 466 if params != nil && params.MachineDetectionTimeout != nil { 467 data.Set("MachineDetectionTimeout", fmt.Sprint(*params.MachineDetectionTimeout)) 468 } 469 if params != nil && params.MachineDetectionSpeechThreshold != nil { 470 data.Set("MachineDetectionSpeechThreshold", fmt.Sprint(*params.MachineDetectionSpeechThreshold)) 471 } 472 if params != nil && params.MachineDetectionSpeechEndThreshold != nil { 473 data.Set("MachineDetectionSpeechEndThreshold", fmt.Sprint(*params.MachineDetectionSpeechEndThreshold)) 474 } 475 if params != nil && params.MachineDetectionSilenceTimeout != nil { 476 data.Set("MachineDetectionSilenceTimeout", fmt.Sprint(*params.MachineDetectionSilenceTimeout)) 477 } 478 if params != nil && params.AmdStatusCallback != nil { 479 data.Set("AmdStatusCallback", *params.AmdStatusCallback) 480 } 481 if params != nil && params.AmdStatusCallbackMethod != nil { 482 data.Set("AmdStatusCallbackMethod", *params.AmdStatusCallbackMethod) 483 } 484 if params != nil && params.Trim != nil { 485 data.Set("Trim", *params.Trim) 486 } 487 if params != nil && params.CallToken != nil { 488 data.Set("CallToken", *params.CallToken) 489 } 490 491 resp, err := c.requestHandler.Post(c.baseURL+path, data, headers) 492 if err != nil { 493 return nil, err 494 } 495 496 defer resp.Body.Close() 497 498 ps := &ApiV2010Participant{} 499 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 500 return nil, err 501 } 502 503 return ps, err 504 } 505 506 // Optional parameters for the method 'DeleteParticipant' 507 type DeleteParticipantParams struct { 508 // The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Participant resources to delete. 509 PathAccountSid *string `json:"PathAccountSid,omitempty"` 510 } 511 512 func (params *DeleteParticipantParams) SetPathAccountSid(PathAccountSid string) *DeleteParticipantParams { 513 params.PathAccountSid = &PathAccountSid 514 return params 515 } 516 517 // Kick a participant from a given conference 518 func (c *ApiService) DeleteParticipant(ConferenceSid string, CallSid string, params *DeleteParticipantParams) error { 519 path := "/2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants/{CallSid}.json" 520 if params != nil && params.PathAccountSid != nil { 521 path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1) 522 } else { 523 path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1) 524 } 525 path = strings.Replace(path, "{"+"ConferenceSid"+"}", ConferenceSid, -1) 526 path = strings.Replace(path, "{"+"CallSid"+"}", CallSid, -1) 527 528 data := url.Values{} 529 headers := make(map[string]interface{}) 530 531 resp, err := c.requestHandler.Delete(c.baseURL+path, data, headers) 532 if err != nil { 533 return err 534 } 535 536 defer resp.Body.Close() 537 538 return nil 539 } 540 541 // Optional parameters for the method 'FetchParticipant' 542 type FetchParticipantParams struct { 543 // The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Participant resource to fetch. 544 PathAccountSid *string `json:"PathAccountSid,omitempty"` 545 } 546 547 func (params *FetchParticipantParams) SetPathAccountSid(PathAccountSid string) *FetchParticipantParams { 548 params.PathAccountSid = &PathAccountSid 549 return params 550 } 551 552 // Fetch an instance of a participant 553 func (c *ApiService) FetchParticipant(ConferenceSid string, CallSid string, params *FetchParticipantParams) (*ApiV2010Participant, error) { 554 path := "/2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants/{CallSid}.json" 555 if params != nil && params.PathAccountSid != nil { 556 path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1) 557 } else { 558 path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1) 559 } 560 path = strings.Replace(path, "{"+"ConferenceSid"+"}", ConferenceSid, -1) 561 path = strings.Replace(path, "{"+"CallSid"+"}", CallSid, -1) 562 563 data := url.Values{} 564 headers := make(map[string]interface{}) 565 566 resp, err := c.requestHandler.Get(c.baseURL+path, data, headers) 567 if err != nil { 568 return nil, err 569 } 570 571 defer resp.Body.Close() 572 573 ps := &ApiV2010Participant{} 574 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 575 return nil, err 576 } 577 578 return ps, err 579 } 580 581 // Optional parameters for the method 'ListParticipant' 582 type ListParticipantParams struct { 583 // The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Participant resources to read. 584 PathAccountSid *string `json:"PathAccountSid,omitempty"` 585 // Whether to return only participants that are muted. Can be: `true` or `false`. 586 Muted *bool `json:"Muted,omitempty"` 587 // Whether to return only participants that are on hold. Can be: `true` or `false`. 588 Hold *bool `json:"Hold,omitempty"` 589 // Whether to return only participants who are coaching another call. Can be: `true` or `false`. 590 Coaching *bool `json:"Coaching,omitempty"` 591 // How many resources to return in each list page. The default is 50, and the maximum is 1000. 592 PageSize *int `json:"PageSize,omitempty"` 593 // Max number of records to return. 594 Limit *int `json:"limit,omitempty"` 595 } 596 597 func (params *ListParticipantParams) SetPathAccountSid(PathAccountSid string) *ListParticipantParams { 598 params.PathAccountSid = &PathAccountSid 599 return params 600 } 601 func (params *ListParticipantParams) SetMuted(Muted bool) *ListParticipantParams { 602 params.Muted = &Muted 603 return params 604 } 605 func (params *ListParticipantParams) SetHold(Hold bool) *ListParticipantParams { 606 params.Hold = &Hold 607 return params 608 } 609 func (params *ListParticipantParams) SetCoaching(Coaching bool) *ListParticipantParams { 610 params.Coaching = &Coaching 611 return params 612 } 613 func (params *ListParticipantParams) SetPageSize(PageSize int) *ListParticipantParams { 614 params.PageSize = &PageSize 615 return params 616 } 617 func (params *ListParticipantParams) SetLimit(Limit int) *ListParticipantParams { 618 params.Limit = &Limit 619 return params 620 } 621 622 // Retrieve a single page of Participant records from the API. Request is executed immediately. 623 func (c *ApiService) PageParticipant(ConferenceSid string, params *ListParticipantParams, pageToken, pageNumber string) (*ListParticipantResponse, error) { 624 path := "/2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants.json" 625 626 if params != nil && params.PathAccountSid != nil { 627 path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1) 628 } else { 629 path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1) 630 } 631 path = strings.Replace(path, "{"+"ConferenceSid"+"}", ConferenceSid, -1) 632 633 data := url.Values{} 634 headers := make(map[string]interface{}) 635 636 if params != nil && params.Muted != nil { 637 data.Set("Muted", fmt.Sprint(*params.Muted)) 638 } 639 if params != nil && params.Hold != nil { 640 data.Set("Hold", fmt.Sprint(*params.Hold)) 641 } 642 if params != nil && params.Coaching != nil { 643 data.Set("Coaching", fmt.Sprint(*params.Coaching)) 644 } 645 if params != nil && params.PageSize != nil { 646 data.Set("PageSize", fmt.Sprint(*params.PageSize)) 647 } 648 649 if pageToken != "" { 650 data.Set("PageToken", pageToken) 651 } 652 if pageNumber != "" { 653 data.Set("Page", pageNumber) 654 } 655 656 resp, err := c.requestHandler.Get(c.baseURL+path, data, headers) 657 if err != nil { 658 return nil, err 659 } 660 661 defer resp.Body.Close() 662 663 ps := &ListParticipantResponse{} 664 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 665 return nil, err 666 } 667 668 return ps, err 669 } 670 671 // Lists Participant records from the API as a list. Unlike stream, this operation is eager and loads 'limit' records into memory before returning. 672 func (c *ApiService) ListParticipant(ConferenceSid string, params *ListParticipantParams) ([]ApiV2010Participant, error) { 673 response, errors := c.StreamParticipant(ConferenceSid, params) 674 675 records := make([]ApiV2010Participant, 0) 676 for record := range response { 677 records = append(records, record) 678 } 679 680 if err := <-errors; err != nil { 681 return nil, err 682 } 683 684 return records, nil 685 } 686 687 // Streams Participant records from the API as a channel stream. This operation lazily loads records as efficiently as possible until the limit is reached. 688 func (c *ApiService) StreamParticipant(ConferenceSid string, params *ListParticipantParams) (chan ApiV2010Participant, chan error) { 689 if params == nil { 690 params = &ListParticipantParams{} 691 } 692 params.SetPageSize(client.ReadLimits(params.PageSize, params.Limit)) 693 694 recordChannel := make(chan ApiV2010Participant, 1) 695 errorChannel := make(chan error, 1) 696 697 response, err := c.PageParticipant(ConferenceSid, params, "", "") 698 if err != nil { 699 errorChannel <- err 700 close(recordChannel) 701 close(errorChannel) 702 } else { 703 go c.streamParticipant(response, params, recordChannel, errorChannel) 704 } 705 706 return recordChannel, errorChannel 707 } 708 709 func (c *ApiService) streamParticipant(response *ListParticipantResponse, params *ListParticipantParams, recordChannel chan ApiV2010Participant, errorChannel chan error) { 710 curRecord := 1 711 712 for response != nil { 713 responseRecords := response.Participants 714 for item := range responseRecords { 715 recordChannel <- responseRecords[item] 716 curRecord += 1 717 if params.Limit != nil && *params.Limit < curRecord { 718 close(recordChannel) 719 close(errorChannel) 720 return 721 } 722 } 723 724 record, err := client.GetNext(c.baseURL, response, c.getNextListParticipantResponse) 725 if err != nil { 726 errorChannel <- err 727 break 728 } else if record == nil { 729 break 730 } 731 732 response = record.(*ListParticipantResponse) 733 } 734 735 close(recordChannel) 736 close(errorChannel) 737 } 738 739 func (c *ApiService) getNextListParticipantResponse(nextPageUrl string) (interface{}, error) { 740 if nextPageUrl == "" { 741 return nil, nil 742 } 743 resp, err := c.requestHandler.Get(nextPageUrl, nil, nil) 744 if err != nil { 745 return nil, err 746 } 747 748 defer resp.Body.Close() 749 750 ps := &ListParticipantResponse{} 751 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 752 return nil, err 753 } 754 return ps, nil 755 } 756 757 // Optional parameters for the method 'UpdateParticipant' 758 type UpdateParticipantParams struct { 759 // The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Participant resources to update. 760 PathAccountSid *string `json:"PathAccountSid,omitempty"` 761 // 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`. 762 Muted *bool `json:"Muted,omitempty"` 763 // 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. 764 Hold *bool `json:"Hold,omitempty"` 765 // 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. 766 HoldUrl *string `json:"HoldUrl,omitempty"` 767 // The HTTP method we should use to call `hold_url`. Can be: `GET` or `POST` and the default is `GET`. 768 HoldMethod *string `json:"HoldMethod,omitempty"` 769 // 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. 770 AnnounceUrl *string `json:"AnnounceUrl,omitempty"` 771 // The HTTP method we should use to call `announce_url`. Can be: `GET` or `POST` and defaults to `POST`. 772 AnnounceMethod *string `json:"AnnounceMethod,omitempty"` 773 // 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). 774 WaitUrl *string `json:"WaitUrl,omitempty"` 775 // 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. 776 WaitMethod *string `json:"WaitMethod,omitempty"` 777 // Whether to play a notification beep to the conference when the participant exits. Can be: `true` or `false`. 778 BeepOnExit *bool `json:"BeepOnExit,omitempty"` 779 // Whether to end the conference when the participant leaves. Can be: `true` or `false` and defaults to `false`. 780 EndConferenceOnExit *bool `json:"EndConferenceOnExit,omitempty"` 781 // 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. 782 Coaching *bool `json:"Coaching,omitempty"` 783 // 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`. 784 CallSidToCoach *string `json:"CallSidToCoach,omitempty"` 785 } 786 787 func (params *UpdateParticipantParams) SetPathAccountSid(PathAccountSid string) *UpdateParticipantParams { 788 params.PathAccountSid = &PathAccountSid 789 return params 790 } 791 func (params *UpdateParticipantParams) SetMuted(Muted bool) *UpdateParticipantParams { 792 params.Muted = &Muted 793 return params 794 } 795 func (params *UpdateParticipantParams) SetHold(Hold bool) *UpdateParticipantParams { 796 params.Hold = &Hold 797 return params 798 } 799 func (params *UpdateParticipantParams) SetHoldUrl(HoldUrl string) *UpdateParticipantParams { 800 params.HoldUrl = &HoldUrl 801 return params 802 } 803 func (params *UpdateParticipantParams) SetHoldMethod(HoldMethod string) *UpdateParticipantParams { 804 params.HoldMethod = &HoldMethod 805 return params 806 } 807 func (params *UpdateParticipantParams) SetAnnounceUrl(AnnounceUrl string) *UpdateParticipantParams { 808 params.AnnounceUrl = &AnnounceUrl 809 return params 810 } 811 func (params *UpdateParticipantParams) SetAnnounceMethod(AnnounceMethod string) *UpdateParticipantParams { 812 params.AnnounceMethod = &AnnounceMethod 813 return params 814 } 815 func (params *UpdateParticipantParams) SetWaitUrl(WaitUrl string) *UpdateParticipantParams { 816 params.WaitUrl = &WaitUrl 817 return params 818 } 819 func (params *UpdateParticipantParams) SetWaitMethod(WaitMethod string) *UpdateParticipantParams { 820 params.WaitMethod = &WaitMethod 821 return params 822 } 823 func (params *UpdateParticipantParams) SetBeepOnExit(BeepOnExit bool) *UpdateParticipantParams { 824 params.BeepOnExit = &BeepOnExit 825 return params 826 } 827 func (params *UpdateParticipantParams) SetEndConferenceOnExit(EndConferenceOnExit bool) *UpdateParticipantParams { 828 params.EndConferenceOnExit = &EndConferenceOnExit 829 return params 830 } 831 func (params *UpdateParticipantParams) SetCoaching(Coaching bool) *UpdateParticipantParams { 832 params.Coaching = &Coaching 833 return params 834 } 835 func (params *UpdateParticipantParams) SetCallSidToCoach(CallSidToCoach string) *UpdateParticipantParams { 836 params.CallSidToCoach = &CallSidToCoach 837 return params 838 } 839 840 // Update the properties of the participant 841 func (c *ApiService) UpdateParticipant(ConferenceSid string, CallSid string, params *UpdateParticipantParams) (*ApiV2010Participant, error) { 842 path := "/2010-04-01/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants/{CallSid}.json" 843 if params != nil && params.PathAccountSid != nil { 844 path = strings.Replace(path, "{"+"AccountSid"+"}", *params.PathAccountSid, -1) 845 } else { 846 path = strings.Replace(path, "{"+"AccountSid"+"}", c.requestHandler.Client.AccountSid(), -1) 847 } 848 path = strings.Replace(path, "{"+"ConferenceSid"+"}", ConferenceSid, -1) 849 path = strings.Replace(path, "{"+"CallSid"+"}", CallSid, -1) 850 851 data := url.Values{} 852 headers := make(map[string]interface{}) 853 854 if params != nil && params.Muted != nil { 855 data.Set("Muted", fmt.Sprint(*params.Muted)) 856 } 857 if params != nil && params.Hold != nil { 858 data.Set("Hold", fmt.Sprint(*params.Hold)) 859 } 860 if params != nil && params.HoldUrl != nil { 861 data.Set("HoldUrl", *params.HoldUrl) 862 } 863 if params != nil && params.HoldMethod != nil { 864 data.Set("HoldMethod", *params.HoldMethod) 865 } 866 if params != nil && params.AnnounceUrl != nil { 867 data.Set("AnnounceUrl", *params.AnnounceUrl) 868 } 869 if params != nil && params.AnnounceMethod != nil { 870 data.Set("AnnounceMethod", *params.AnnounceMethod) 871 } 872 if params != nil && params.WaitUrl != nil { 873 data.Set("WaitUrl", *params.WaitUrl) 874 } 875 if params != nil && params.WaitMethod != nil { 876 data.Set("WaitMethod", *params.WaitMethod) 877 } 878 if params != nil && params.BeepOnExit != nil { 879 data.Set("BeepOnExit", fmt.Sprint(*params.BeepOnExit)) 880 } 881 if params != nil && params.EndConferenceOnExit != nil { 882 data.Set("EndConferenceOnExit", fmt.Sprint(*params.EndConferenceOnExit)) 883 } 884 if params != nil && params.Coaching != nil { 885 data.Set("Coaching", fmt.Sprint(*params.Coaching)) 886 } 887 if params != nil && params.CallSidToCoach != nil { 888 data.Set("CallSidToCoach", *params.CallSidToCoach) 889 } 890 891 resp, err := c.requestHandler.Post(c.baseURL+path, data, headers) 892 if err != nil { 893 return nil, err 894 } 895 896 defer resp.Body.Close() 897 898 ps := &ApiV2010Participant{} 899 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 900 return nil, err 901 } 902 903 return ps, err 904 }