class Twilio::REST::Api::V2010::AccountContext::CallList

Public Class Methods

new(version, account_sid: nil) click to toggle source

Initialize the CallList @param [Version] version Version that contains the resource @param [String] account_sid The SID of the

{Account}[https://www.twilio.com/docs/iam/api/account] that created this Call
resource.

@return [CallList] CallList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/api/v2010/account/call.rb
22 def initialize(version, account_sid: nil)
23   super(version)
24 
25   # Path Solution
26   @solution = {account_sid: account_sid}
27   @uri = "/Accounts/#{@solution[:account_sid]}/Calls.json"
28 
29   # Components
30   @feedback_summaries = nil
31 end

Public Instance Methods

create(to: nil, from: nil, method: :unset, fallback_url: :unset, fallback_method: :unset, status_callback: :unset, status_callback_event: :unset, status_callback_method: :unset, send_digits: :unset, timeout: :unset, record: :unset, recording_channels: :unset, recording_status_callback: :unset, recording_status_callback_method: :unset, sip_auth_username: :unset, sip_auth_password: :unset, machine_detection: :unset, machine_detection_timeout: :unset, recording_status_callback_event: :unset, trim: :unset, caller_id: :unset, machine_detection_speech_threshold: :unset, machine_detection_speech_end_threshold: :unset, machine_detection_silence_timeout: :unset, async_amd: :unset, async_amd_status_callback: :unset, async_amd_status_callback_method: :unset, byoc: :unset, call_reason: :unset, call_token: :unset, recording_track: :unset, time_limit: :unset, url: :unset, twiml: :unset, application_sid: :unset) click to toggle source

Create the CallInstance @param [String] to The phone number, SIP address, or client identifier to call. @param [String] from The phone number or client identifier to use as the caller

id. 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.

@param [String] method The HTTP method we should use when calling the `url`

parameter's value. Can be: `GET` or `POST` and the default is `POST`. If an
`application_sid` parameter is present, this parameter is ignored.

@param [String] fallback_url The URL that we call using the `fallback_method` if

an error occurs when requesting or executing the TwiML at `url`. If an
`application_sid` parameter is present, this parameter is ignored.

@param [String] fallback_method The HTTP method that we should use to request

the `fallback_url`. Can be: `GET` or `POST` and the default is `POST`. If an
`application_sid` parameter is present, this parameter is ignored.

@param [String] status_callback The URL we should call using the

`status_callback_method` to send status information to your application. If no
`status_callback_event` is specified, we will send the `completed` status. If an
`application_sid` parameter is present, this parameter is ignored. URLs must
contain a valid hostname (underscores are not permitted).

@param [Array] status_callback_event The call progress events that we

will send to the `status_callback` URL. Can be: `initiated`, `ringing`,
`answered`, and `completed`. If no event is specified, we send the `completed`
status. If you want to receive multiple events, specify each one in a separate
`status_callback_event` parameter. See the code sample for {monitoring call
progress}[https://www.twilio.com/docs/voice/api/call-resource?code-sample=code-create-a-call-resource-and-specify-a-statuscallbackevent&code-sdk-version=json].
If an `application_sid` is present, this parameter is ignored.

@param [String] status_callback_method The HTTP method we should use when

calling the `status_callback` URL. Can be: `GET` or `POST` and the default is
`POST`. If an `application_sid` parameter is present, this parameter is ignored.

@param [String] send_digits A string of keys to dial after connecting to the

number, maximum of 32 digits. Valid digits in the string include: any digit
(`0`-`9`), '`#`', '`*`' and '`w`', to insert a half second pause. For example,
if you connected to a company phone number and wanted to pause for one second,
and then dial extension 1234 followed by the pound key, the value of this
parameter would be `ww1234#`. Remember to URL-encode this string, since the
'`#`' character has special meaning in a URL. If both `SendDigits` and
`MachineDetection` parameters are provided, then `MachineDetection` will be
ignored.

@param [String] timeout The integer number of seconds that we should allow the

phone to ring before assuming there is no answer. The default is `60` seconds
and the maximum is `600` seconds. For some call flows, we will add a 5-second
buffer to the timeout value you provide. For this reason, a timeout value of 10
seconds could result in an actual timeout closer to 15 seconds. You can set this
to a short time, such as `15` seconds, to hang up before reaching an answering
machine or voicemail.

@param [Boolean] record Whether to record the call. Can be `true` to record the

phone call, or `false` to not. The default is `false`. The `recording_url` is
sent to the `status_callback` URL.

@param [String] recording_channels The number of channels in the final

recording. Can be: `mono` or `dual`. The default is `mono`. `mono` records both
legs of the call in a single channel of the recording file. `dual` records each
leg to a separate channel of the recording file. The first channel of a
dual-channel recording contains the parent call and the second channel contains
the child call.

@param [String] recording_status_callback The URL that we call when the

recording is available to be accessed.

@param [String] recording_status_callback_method The HTTP method we should use

when calling the `recording_status_callback` URL. Can be: `GET` or `POST` and
the default is `POST`.

@param [String] sip_auth_username The username used to authenticate the caller

making a SIP call.

@param [String] sip_auth_password The password required to authenticate the user

account specified in `sip_auth_username`.

@param [String] machine_detection 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. If `send_digits` is provided, this parameter is
ignored. For more information, see {Answering Machine
Detection}[https://www.twilio.com/docs/voice/answering-machine-detection].

@param [String] machine_detection_timeout 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.

@param [Array] recording_status_callback_event The recording status

events that will trigger calls to the URL specified in
`recording_status_callback`. Can be: `in-progress`, `completed` and `absent`.
Defaults to `completed`. Separate  multiple values with a space.

@param [String] trim Whether to trim any leading and trailing silence from the

recording. Can be: `trim-silence` or `do-not-trim` and the default is
`trim-silence`.

@param [String] caller_id The phone number, SIP address, or Client identifier

that made this call. Phone numbers are in {E.164
format}[https://wwnw.twilio.com/docs/glossary/what-e164] (e.g., +16175551212).
SIP addresses are formatted as `name@company.com`.

@param [String] machine_detection_speech_threshold 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.

@param [String] machine_detection_speech_end_threshold The number of

milliseconds of silence after speech activity at which point the speech activity
is considered complete. Possible Values: 500-5000. Default: 1200.

@param [String] machine_detection_silence_timeout The number of milliseconds of

initial silence after which an `unknown` AnsweredBy result will be returned.
Possible Values: 2000-10000. Default: 5000.

@param [String] async_amd Select whether to perform answering machine detection

in the background. Default, blocks the execution of the call until Answering
Machine Detection is completed. Can be: `true` or `false`.

@param [String] async_amd_status_callback The URL that we should call using the

`async_amd_status_callback_method` to notify customer application whether the
call was answered by human, machine or fax.

@param [String] async_amd_status_callback_method The HTTP method we should use

when calling the `async_amd_status_callback` URL. Can be: `GET` or `POST` and
the default is `POST`.

@param [String] byoc 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)

@param [String] call_reason 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)

@param [String] call_token A token string needed to invoke a forwarded call. A

call_token is generated when an incoming call is received on a Twilio number.
this field should be populated by the incoming call's call_token to make this
outgoing call as a forwarded call of incoming call. A forwarded call should bear
the same caller-id of incoming call.

@param [String] recording_track 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 generated
from Twilio. `both` records the audio that is received and generated by Twilio.

@param [String] time_limit The maximum duration of the call in seconds.

Constraints depend on account and configuration.

@param [String] url The absolute URL that returns the TwiML instructions for the

call. We will call this URL using the `method` when the call connects. For more
information, see the {Url
Parameter}[https://www.twilio.com/docs/voice/make-calls#specify-a-url-parameter]
section in {Making Calls}[https://www.twilio.com/docs/voice/make-calls].

@param [String] twiml TwiML instructions for the call Twilio will use without

fetching Twiml from url parameter. If both `twiml` and `url` are provided then
`twiml` parameter will be ignored.

@param [String] application_sid The SID of the Application resource that will

handle the call, if the call will be handled by an application.

@return [CallInstance] Created CallInstance

    # File lib/twilio-ruby/rest/api/v2010/account/call.rb
167 def create(to: nil, from: nil, method: :unset, fallback_url: :unset, fallback_method: :unset, status_callback: :unset, status_callback_event: :unset, status_callback_method: :unset, send_digits: :unset, timeout: :unset, record: :unset, recording_channels: :unset, recording_status_callback: :unset, recording_status_callback_method: :unset, sip_auth_username: :unset, sip_auth_password: :unset, machine_detection: :unset, machine_detection_timeout: :unset, recording_status_callback_event: :unset, trim: :unset, caller_id: :unset, machine_detection_speech_threshold: :unset, machine_detection_speech_end_threshold: :unset, machine_detection_silence_timeout: :unset, async_amd: :unset, async_amd_status_callback: :unset, async_amd_status_callback_method: :unset, byoc: :unset, call_reason: :unset, call_token: :unset, recording_track: :unset, time_limit: :unset, url: :unset, twiml: :unset, application_sid: :unset)
168   data = Twilio::Values.of({
169       'To' => to,
170       'From' => from,
171       'Url' => url,
172       'Twiml' => twiml,
173       'ApplicationSid' => application_sid,
174       'Method' => method,
175       'FallbackUrl' => fallback_url,
176       'FallbackMethod' => fallback_method,
177       'StatusCallback' => status_callback,
178       'StatusCallbackEvent' => Twilio.serialize_list(status_callback_event) { |e| e },
179       'StatusCallbackMethod' => status_callback_method,
180       'SendDigits' => send_digits,
181       'Timeout' => timeout,
182       'Record' => record,
183       'RecordingChannels' => recording_channels,
184       'RecordingStatusCallback' => recording_status_callback,
185       'RecordingStatusCallbackMethod' => recording_status_callback_method,
186       'SipAuthUsername' => sip_auth_username,
187       'SipAuthPassword' => sip_auth_password,
188       'MachineDetection' => machine_detection,
189       'MachineDetectionTimeout' => machine_detection_timeout,
190       'RecordingStatusCallbackEvent' => Twilio.serialize_list(recording_status_callback_event) { |e| e },
191       'Trim' => trim,
192       'CallerId' => caller_id,
193       'MachineDetectionSpeechThreshold' => machine_detection_speech_threshold,
194       'MachineDetectionSpeechEndThreshold' => machine_detection_speech_end_threshold,
195       'MachineDetectionSilenceTimeout' => machine_detection_silence_timeout,
196       'AsyncAmd' => async_amd,
197       'AsyncAmdStatusCallback' => async_amd_status_callback,
198       'AsyncAmdStatusCallbackMethod' => async_amd_status_callback_method,
199       'Byoc' => byoc,
200       'CallReason' => call_reason,
201       'CallToken' => call_token,
202       'RecordingTrack' => recording_track,
203       'TimeLimit' => time_limit,
204   })
205 
206   payload = @version.create('POST', @uri, data: data)
207 
208   CallInstance.new(@version, payload, account_sid: @solution[:account_sid], )
209 end
each() { |x| ... } click to toggle source

When passed a block, yields CallInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.

    # File lib/twilio-ruby/rest/api/v2010/account/call.rb
304 def each
305   limits = @version.read_limits
306 
307   page = self.page(page_size: limits[:page_size], )
308 
309   @version.stream(page,
310                   limit: limits[:limit],
311                   page_limit: limits[:page_limit]).each {|x| yield x}
312 end
feedback_summaries(sid=:unset) click to toggle source

Access the feedback_summaries @param [String] sid A 34 character string that uniquely identifies this

resource.

@return [FeedbackSummaryList] @return [FeedbackSummaryContext] if sid was passed.

    # File lib/twilio-ruby/rest/api/v2010/account/call.rb
377 def feedback_summaries(sid=:unset)
378   raise ArgumentError, 'sid cannot be nil' if sid.nil?
379 
380   if sid != :unset
381     return FeedbackSummaryContext.new(@version, @solution[:account_sid], sid, )
382   end
383 
384     @feedback_summaries ||= FeedbackSummaryList.new(@version, account_sid: @solution[:account_sid], )
385 end
get_page(target_url) click to toggle source

Retrieve a single page of CallInstance records from the API. Request is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page of CallInstance

    # File lib/twilio-ruby/rest/api/v2010/account/call.rb
363 def get_page(target_url)
364   response = @version.domain.request(
365       'GET',
366       target_url
367   )
368   CallPage.new(@version, response, @solution)
369 end
list(to: :unset, from: :unset, parent_call_sid: :unset, status: :unset, start_time_before: :unset, start_time: :unset, start_time_after: :unset, end_time_before: :unset, end_time: :unset, end_time_after: :unset, limit: nil, page_size: nil) click to toggle source

Lists CallInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] to Only show calls made to this phone number, SIP address,

Client identifier or SIM SID.

@param [String] from Only include calls from this phone number, SIP address,

Client identifier or SIM SID.

@param [String] parent_call_sid Only include calls spawned by calls with this

SID.

@param [call.Status] status The status of the calls to include. Can be:

`queued`, `ringing`, `in-progress`, `canceled`, `completed`, `failed`, `busy`,
or `no-answer`.

@param [Time] start_time_before Only include calls that started on this date @param [Time] start_time Only include calls that started on this date @param [Time] start_time_after Only include calls that started on this date @param [Time] end_time_before Only include calls that ended on this date @param [Time] end_time Only include calls that ended on this date @param [Time] end_time_after Only include calls that ended on this date @param [Integer] limit Upper limit for the number of records to return. stream()

guarantees to never return more than limit.  Default is no limit

@param [Integer] page_size Number of records to fetch per request, when

not set will use the default value of 50 records.  If no page_size is defined
but a limit is defined, stream() will attempt to read the limit with the most
efficient page size, i.e. min(limit, 1000)

@return [Array] Array of up to limit results

    # File lib/twilio-ruby/rest/api/v2010/account/call.rb
237 def list(to: :unset, from: :unset, parent_call_sid: :unset, status: :unset, start_time_before: :unset, start_time: :unset, start_time_after: :unset, end_time_before: :unset, end_time: :unset, end_time_after: :unset, limit: nil, page_size: nil)
238   self.stream(
239       to: to,
240       from: from,
241       parent_call_sid: parent_call_sid,
242       status: status,
243       start_time_before: start_time_before,
244       start_time: start_time,
245       start_time_after: start_time_after,
246       end_time_before: end_time_before,
247       end_time: end_time,
248       end_time_after: end_time_after,
249       limit: limit,
250       page_size: page_size
251   ).entries
252 end
page(to: :unset, from: :unset, parent_call_sid: :unset, status: :unset, start_time_before: :unset, start_time: :unset, start_time_after: :unset, end_time_before: :unset, end_time: :unset, end_time_after: :unset, page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of CallInstance records from the API. Request is executed immediately. @param [String] to Only show calls made to this phone number, SIP address,

Client identifier or SIM SID.

@param [String] from Only include calls from this phone number, SIP address,

Client identifier or SIM SID.

@param [String] parent_call_sid Only include calls spawned by calls with this

SID.

@param [call.Status] status The status of the calls to include. Can be:

`queued`, `ringing`, `in-progress`, `canceled`, `completed`, `failed`, `busy`,
or `no-answer`.

@param [Time] start_time_before Only include calls that started on this date @param [Time] start_time Only include calls that started on this date @param [Time] start_time_after Only include calls that started on this date @param [Time] end_time_before Only include calls that ended on this date @param [Time] end_time Only include calls that ended on this date @param [Time] end_time_after Only include calls that ended on this date @param [String] page_token PageToken provided by the API @param [Integer] page_number Page Number, this value is simply for client state @param [Integer] page_size Number of records to return, defaults to 50 @return [Page] Page of CallInstance

    # File lib/twilio-ruby/rest/api/v2010/account/call.rb
336 def page(to: :unset, from: :unset, parent_call_sid: :unset, status: :unset, start_time_before: :unset, start_time: :unset, start_time_after: :unset, end_time_before: :unset, end_time: :unset, end_time_after: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
337   params = Twilio::Values.of({
338       'To' => to,
339       'From' => from,
340       'ParentCallSid' => parent_call_sid,
341       'Status' => status,
342       'StartTime<' => Twilio.serialize_iso8601_datetime(start_time_before),
343       'StartTime' => Twilio.serialize_iso8601_datetime(start_time),
344       'StartTime>' => Twilio.serialize_iso8601_datetime(start_time_after),
345       'EndTime<' => Twilio.serialize_iso8601_datetime(end_time_before),
346       'EndTime' => Twilio.serialize_iso8601_datetime(end_time),
347       'EndTime>' => Twilio.serialize_iso8601_datetime(end_time_after),
348       'PageToken' => page_token,
349       'Page' => page_number,
350       'PageSize' => page_size,
351   })
352 
353   response = @version.page('GET', @uri, params: params)
354 
355   CallPage.new(@version, response, @solution)
356 end
stream(to: :unset, from: :unset, parent_call_sid: :unset, status: :unset, start_time_before: :unset, start_time: :unset, start_time_after: :unset, end_time_before: :unset, end_time: :unset, end_time_after: :unset, limit: nil, page_size: nil) click to toggle source

Streams CallInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] to Only show calls made to this phone number, SIP address,

Client identifier or SIM SID.

@param [String] from Only include calls from this phone number, SIP address,

Client identifier or SIM SID.

@param [String] parent_call_sid Only include calls spawned by calls with this

SID.

@param [call.Status] status The status of the calls to include. Can be:

`queued`, `ringing`, `in-progress`, `canceled`, `completed`, `failed`, `busy`,
or `no-answer`.

@param [Time] start_time_before Only include calls that started on this date @param [Time] start_time Only include calls that started on this date @param [Time] start_time_after Only include calls that started on this date @param [Time] end_time_before Only include calls that ended on this date @param [Time] end_time Only include calls that ended on this date @param [Time] end_time_after Only include calls that ended on this date @param [Integer] limit Upper limit for the number of records to return. stream()

guarantees to never return more than limit. Default is no limit.

@param [Integer] page_size Number of records to fetch per request, when

not set will use the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the limit with the most
efficient page size, i.e. min(limit, 1000)

@return [Enumerable] Enumerable that will yield up to limit results

    # File lib/twilio-ruby/rest/api/v2010/account/call.rb
280 def stream(to: :unset, from: :unset, parent_call_sid: :unset, status: :unset, start_time_before: :unset, start_time: :unset, start_time_after: :unset, end_time_before: :unset, end_time: :unset, end_time_after: :unset, limit: nil, page_size: nil)
281   limits = @version.read_limits(limit, page_size)
282 
283   page = self.page(
284       to: to,
285       from: from,
286       parent_call_sid: parent_call_sid,
287       status: status,
288       start_time_before: start_time_before,
289       start_time: start_time,
290       start_time_after: start_time_after,
291       end_time_before: end_time_before,
292       end_time: end_time,
293       end_time_after: end_time_after,
294       page_size: limits[:page_size],
295   )
296 
297   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
298 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/api/v2010/account/call.rb
389 def to_s
390   '#<Twilio.Api.V2010.CallList>'
391 end