Class: Twilio::REST::Api::V2010::AccountContext::CallList

Inherits:
ListResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/api/v2010/account/call.rb,
lib/twilio-ruby/rest/api/v2010/account/call/feedback_summary.rb

Defined Under Namespace

Classes: FeedbackSummaryContext, FeedbackSummaryInstance, FeedbackSummaryList, FeedbackSummaryPage

Instance Method Summary collapse

Constructor Details

#initialize(version, account_sid: nil) ⇒ CallList

Initialize the CallList

Parameters:



22
23
24
25
26
27
28
29
30
31
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 22

def initialize(version, account_sid: nil)
  super(version)

  # Path Solution
  @solution = {account_sid: }
  @uri = "/Accounts/#{@solution[:account_sid]}/Calls.json"

  # Components
  @feedback_summaries = nil
end

Instance Method Details

#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, if_machine: :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, url: :unset, application_sid: :unset) ⇒ CallInstance

Retrieve a single page of CallInstance records from the API. Request is executed immediately.

Parameters:

  • to (String) (defaults to: nil)

    The phone number, SIP address, or client identifier to call.

  • from (String) (defaults to: nil)

    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](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.

  • method (String) (defaults to: :unset)

    The HTTP method Twilio should use when making its request to the ‘Url` parameter’s value. Defaults to ‘POST`. If an `ApplicationSid` parameter is present, this parameter is ignored.

  • fallback_url (String) (defaults to: :unset)

    A URL that Twilio will request if an error occurs requesting or executing the TwiML at ‘Url`. If an `ApplicationSid` parameter is present, this parameter is ignored.

  • fallback_method (String) (defaults to: :unset)

    The HTTP method that Twilio should use to request the ‘FallbackUrl`. Must be either `GET` or `POST`. Defaults to `POST`. If an `ApplicationSid` parameter is present, this parameter is ignored.

  • status_callback (String) (defaults to: :unset)

    A URL that Twilio will send asynchronous webhook requests to on every call event specified in the ‘StatusCallbackEvent` parameter. If no event is specified, Twilio will send `completed` by default. If an `ApplicationSid` parameter is present, this parameter is ignored. URLs must contain a valid hostname (underscores are not permitted).

  • status_callback_event (String) (defaults to: :unset)

    The call progress events that will trigger a webhook from Twilio. Available values are ‘initiated`, `ringing`, `answered`, and `completed`. If no event is specified, defaults to `completed`. If you want to receive multiple events, please provide multiple `StatusCallbackEvent` values as individual parameters in the `POST` request. See the code sample for [monitoring call progress](www.twilio.com/docs/voice/api/call?code-sample=code-create-a-call-and-specify-a-statuscallbackevent). If an `ApplicationSid` is present, this parameter is ignored.

  • status_callback_method (String) (defaults to: :unset)

    The HTTP method Twilio should use when requesting the ‘StatusCallback` URL. Defaults to `POST`. If an `ApplicationSid` parameter is present, this parameter is ignored.

  • send_digits (String) (defaults to: :unset)

    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, dial extension 1234, and then the pound key, use ‘SendDigits=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.

  • if_machine (String) (defaults to: :unset)

    The if_machine

  • timeout (String) (defaults to: :unset)

    The integer number of seconds that Twilio should allow the phone to ring before assuming there is no answer. Default is ‘60` seconds, the maximum is `600` seconds. For some call flows, Twilio will add a 5-second buffer to the timeout value provided, so if you enter a timeout value of 10 seconds, you could see actual timeout closer to 15 seconds. Note, you could set this to a low value like `15` to hang up before reaching an answering machine or voicemail.

  • record (Boolean) (defaults to: :unset)

    Set this parameter to ‘true` to record the entirety of a phone call. The `RecordingUrl` will be sent to the `StatusCallback` URL. Defaults to false.

  • recording_channels (String) (defaults to: :unset)

    ‘mono` or `dual` – defaults to `mono`. Set this parameter to specify the number of channels in the final recording. In a mono-channel recording, both legs of the call are mixed down into a single channel within a single recording file. With dual-channel recording, both legs use separate channels within a single recording file. In dual-channel recordings, the parent call will always be in the first channel, and the child call will always be in the second channel.

  • recording_status_callback (String) (defaults to: :unset)

    A URL that Twilio will send a webhook request to when the recording is available for access.

  • recording_status_callback_method (String) (defaults to: :unset)

    The HTTP method Twilio should use when requesting the ‘RecordingStatusCallback` URL. Defaults to `POST`.

  • sip_auth_username (String) (defaults to: :unset)

    The sip_auth_username

  • sip_auth_password (String) (defaults to: :unset)

    The sip_auth_password

  • machine_detection (String) (defaults to: :unset)

    Detect if a human, answering machine, or fax has picked up the call. Use ‘Enable` if you would like Twilio to return an `AnsweredBy` value as soon as it identifies the called party. If you would like to leave a message on an answering machine, specify `DetectMessageEnd`. If both `SendDigits` and `MachineDetection` parameters are provided, then MachineDetection will be ignored. [Detailed documentation is here](www.twilio.com/docs/voice/answering-machine-detection).

  • machine_detection_timeout (String) (defaults to: :unset)

    The number of seconds that Twilio should attempt to perform answering machine detection before timing out and firing a voice request with ‘AnsweredBy` of `unknown`. Defaults to 30 seconds.

  • recording_status_callback_event (String) (defaults to: :unset)

    The recording status events that will trigger Twilio to send webhooks on to the URL specified in ‘RecordingStatusCallback`. The available values are `in-progress`, `completed`, and `failed`. Defaults are `completed` and `failed`. To specify multiple values, separate them with a space. If any values are specified, the defaults are no longer applicable.

  • trim (String) (defaults to: :unset)

    ‘trim-silence` or `do-not-trim`. Set this parameter to define whether leading and trailing silence is trimmed from the recording. Defaults to `trim-silence`.

  • caller_id (String) (defaults to: :unset)

    The phone number, SIP address, or Client identifier that made this Call. Phone numbers are in [E.164 format](www.twilio.com/docs/glossary/what-e164) (e.g., +16175551212). SIP addresses are formatted as ‘[email protected]`.

  • url (String) (defaults to: :unset)

    The fully qualified URL that hosts instructions for the call. Twilio will consult this URL when the call connects. See the [Url Parameter](www.twilio.com/docs/voice/make-calls#specify-a-url-parameter) details in [Making Calls](www.twilio.com/docs/voice/make-calls) for more details.

  • application_sid (String) (defaults to: :unset)

    The 34-character SID of the application Twilio should use to handle this phone call. If this parameter is present, Twilio will ignore all of the voice URLs passed and use the URLs set on the application. See the [ApplicationSid Parameter](www.twilio.com/docs/voice/make-calls#specify-an-applicationsid-parameter) section in [Making Calls](www.twilio.com/docs/voice/make-calls) for more details.

Returns:



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 130

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, if_machine: :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, url: :unset, application_sid: :unset)
  data = Twilio::Values.of({
      'To' => to,
      'From' => from,
      'Url' => url,
      'ApplicationSid' => application_sid,
      'Method' => method,
      'FallbackUrl' => fallback_url,
      'FallbackMethod' => fallback_method,
      'StatusCallback' => status_callback,
      'StatusCallbackEvent' => Twilio.serialize_list(status_callback_event) { |e| e },
      'StatusCallbackMethod' => status_callback_method,
      'SendDigits' => send_digits,
      'IfMachine' => if_machine,
      'Timeout' => timeout,
      'Record' => record,
      'RecordingChannels' => recording_channels,
      'RecordingStatusCallback' => recording_status_callback,
      'RecordingStatusCallbackMethod' => recording_status_callback_method,
      'SipAuthUsername' => sip_auth_username,
      'SipAuthPassword' => sip_auth_password,
      'MachineDetection' => machine_detection,
      'MachineDetectionTimeout' => machine_detection_timeout,
      'RecordingStatusCallbackEvent' => Twilio.serialize_list(recording_status_callback_event) { |e| e },
      'Trim' => trim,
      'CallerId' => caller_id,
  })

  payload = @version.create(
      'POST',
      @uri,
      data: data
  )

  CallInstance.new(@version, payload, account_sid: @solution[:account_sid], )
end

#eachObject

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



260
261
262
263
264
265
266
267
268
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 260

def each
  limits = @version.read_limits

  page = self.page(page_size: limits[:page_size], )

  @version.stream(page,
                  limit: limits[:limit],
                  page_limit: limits[:page_limit]).each {|x| yield x}
end

#feedback_summaries(sid = :unset) ⇒ FeedbackSummaryList, FeedbackSummaryContext

Access the feedback_summaries

Parameters:

  • sid (String) (defaults to: :unset)

    The sid

Returns:

Raises:

  • (ArgumentError)


334
335
336
337
338
339
340
341
342
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 334

def feedback_summaries(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return FeedbackSummaryContext.new(@version, @solution[:account_sid], sid, )
  end

    @feedback_summaries ||= FeedbackSummaryList.new(@version, account_sid: @solution[:account_sid], )
end

#get_page(target_url) ⇒ Page

Retrieve a single page of CallInstance records from the API. Request is executed immediately.

Parameters:

  • target_url (String)

    API-generated URL for the requested results page

Returns:

  • (Page)

    Page of CallInstance



321
322
323
324
325
326
327
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 321

def get_page(target_url)
  response = @version.domain.request(
      'GET',
      target_url
  )
  CallPage.new(@version, response, @solution)
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) ⇒ Array

Lists CallInstance records from the API as a list. Unlike stream(), this operation is eager and will load ‘limit` records into memory before returning.

Parameters:

  • to (String) (defaults to: :unset)

    Only show calls to this phone number, SIP address, Client identifier or SIM SID.

  • from (String) (defaults to: :unset)

    Only show calls from this phone number, SIP address, Client identifier or SIM SID.

  • parent_call_sid (String) (defaults to: :unset)

    Only show calls spawned by the Call with this SID.

  • status (call.Status) (defaults to: :unset)

    Only show calls currently in the specified status. May be ‘queued`, `ringing`, `in-progress`, `canceled`, `completed`, `failed`, `busy`, or `no-answer`.

  • start_time_before (Time) (defaults to: :unset)

    StartTime to filter on

  • start_time (Time) (defaults to: :unset)

    StartTime to filter on

  • start_time_after (Time) (defaults to: :unset)

    StartTime to filter on

  • end_time_before (Time) (defaults to: :unset)

    EndTime to filter on

  • end_time (Time) (defaults to: :unset)

    EndTime to filter on

  • end_time_after (Time) (defaults to: :unset)

    EndTime to filter on

  • limit (Integer) (defaults to: nil)

    Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit

  • page_size (Integer) (defaults to: nil)

    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)

Returns:

  • (Array)

    Array of up to limit results



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 193

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)
  self.stream(
      to: to,
      from: from,
      parent_call_sid: parent_call_sid,
      status: status,
      start_time_before: start_time_before,
      start_time: start_time,
      start_time_after: start_time_after,
      end_time_before: end_time_before,
      end_time: end_time,
      end_time_after: end_time_after,
      limit: limit,
      page_size: page_size
  ).entries
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) ⇒ Page

Retrieve a single page of CallInstance records from the API. Request is executed immediately.

Parameters:

  • to (String) (defaults to: :unset)

    Only show calls to this phone number, SIP address, Client identifier or SIM SID.

  • from (String) (defaults to: :unset)

    Only show calls from this phone number, SIP address, Client identifier or SIM SID.

  • parent_call_sid (String) (defaults to: :unset)

    Only show calls spawned by the Call with this SID.

  • status (call.Status) (defaults to: :unset)

    Only show calls currently in the specified status. May be ‘queued`, `ringing`, `in-progress`, `canceled`, `completed`, `failed`, `busy`, or `no-answer`.

  • start_time_before (Time) (defaults to: :unset)

    StartTime to filter on

  • start_time (Time) (defaults to: :unset)

    StartTime to filter on

  • start_time_after (Time) (defaults to: :unset)

    StartTime to filter on

  • end_time_before (Time) (defaults to: :unset)

    EndTime to filter on

  • end_time (Time) (defaults to: :unset)

    EndTime to filter on

  • end_time_after (Time) (defaults to: :unset)

    EndTime to filter on

  • page_token (String) (defaults to: :unset)

    PageToken provided by the API

  • page_number (Integer) (defaults to: :unset)

    Page Number, this value is simply for client state

  • page_size (Integer) (defaults to: :unset)

    Number of records to return, defaults to 50

Returns:

  • (Page)

    Page of CallInstance



292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 292

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)
  params = Twilio::Values.of({
      'To' => to,
      'From' => from,
      'ParentCallSid' => parent_call_sid,
      'Status' => status,
      'StartTime<' => Twilio.serialize_iso8601_datetime(start_time_before),
      'StartTime' => Twilio.serialize_iso8601_datetime(start_time),
      'StartTime>' => Twilio.serialize_iso8601_datetime(start_time_after),
      'EndTime<' => Twilio.serialize_iso8601_datetime(end_time_before),
      'EndTime' => Twilio.serialize_iso8601_datetime(end_time),
      'EndTime>' => Twilio.serialize_iso8601_datetime(end_time_after),
      'PageToken' => page_token,
      'Page' => page_number,
      'PageSize' => page_size,
  })
  response = @version.page(
      'GET',
      @uri,
      params
  )
  CallPage.new(@version, response, @solution)
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) ⇒ Enumerable

Streams CallInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached.

Parameters:

  • to (String) (defaults to: :unset)

    Only show calls to this phone number, SIP address, Client identifier or SIM SID.

  • from (String) (defaults to: :unset)

    Only show calls from this phone number, SIP address, Client identifier or SIM SID.

  • parent_call_sid (String) (defaults to: :unset)

    Only show calls spawned by the Call with this SID.

  • status (call.Status) (defaults to: :unset)

    Only show calls currently in the specified status. May be ‘queued`, `ringing`, `in-progress`, `canceled`, `completed`, `failed`, `busy`, or `no-answer`.

  • start_time_before (Time) (defaults to: :unset)

    StartTime to filter on

  • start_time (Time) (defaults to: :unset)

    StartTime to filter on

  • start_time_after (Time) (defaults to: :unset)

    StartTime to filter on

  • end_time_before (Time) (defaults to: :unset)

    EndTime to filter on

  • end_time (Time) (defaults to: :unset)

    EndTime to filter on

  • end_time_after (Time) (defaults to: :unset)

    EndTime to filter on

  • limit (Integer) (defaults to: nil)

    Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit.

  • page_size (Integer) (defaults to: nil)

    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)

Returns:

  • (Enumerable)

    Enumerable that will yield up to limit results



236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 236

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)
  limits = @version.read_limits(limit, page_size)

  page = self.page(
      to: to,
      from: from,
      parent_call_sid: parent_call_sid,
      status: status,
      start_time_before: start_time_before,
      start_time: start_time,
      start_time_after: start_time_after,
      end_time_before: end_time_before,
      end_time: end_time,
      end_time_after: end_time_after,
      page_size: limits[:page_size],
  )

  @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
end

#to_sObject

Provide a user friendly representation



346
347
348
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 346

def to_s
  '#<Twilio.Api.V2010.CallList>'
end