class TwilioTestToolkit::CallInProgress

Models a call

Attributes

called[R]
direction[R]
from_number[R]
http_method[R]
initial_path[R]
is_machine[R]
options[R]
sid[R]
to_number[R]

Public Class Methods

new(initial_path, from_number, to_number, options = {}) click to toggle source

Initiate a call. Options:

  • :method - specify the http method of the initial api call

  • :call_sid - specify an optional fixed value to be passed as params

  • :is_machine - controls params

# File lib/twilio-test-toolkit/call_in_progress.rb, line 15
def initialize(initial_path, from_number, to_number, options = {})
  default_options = {
    :method     => :post,
    :direction  => 'inbound',
    :is_machine => false
  }

  @options = default_options.merge(options)

  # Save our variables for later
  @initial_path = initial_path
  @from_number  = from_number
  @to_number    = to_number
  @is_machine   = @options[:is_machine]
  @called       = @options[:called]
  @direction    = @options[:direction]
  @http_method  = @options[:method]

  # Generate an initial call SID if we don't have one
  if (options[:call_sid].nil?)
    @sid = UUIDTools::UUID.random_create.to_s
  else
    @sid = options[:call_sid]
  end

  # We are the root call
  self.root_call = self

  # Create the request
  request_for_twiml!(@initial_path, @options)
end