Class: VoiceML::Call

Inherits:
Object
  • Object
show all
Defined in:
lib/voiceml/models/calls.rb

Overview

A Twilio-compatible Call resource. Returned by ‘client.calls.create`, `client.calls.get`, `client.calls.update`, and listed in `CallList#calls`.

Constant Summary collapse

ATTRIBUTES =
%w[
  sid account_sid api_version to to_formatted from from_formatted
  parent_call_sid caller_name forwarded_from status direction
  answered_by start_time end_time duration price price_unit
  phone_number_sid annotation group_sid queue_time trunk_sid
  date_created date_updated uri subresource_uris
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Call

Returns a new instance of Call.



19
20
21
22
23
24
# File 'lib/voiceml/models/calls.rb', line 19

def initialize(attrs = {})
  ATTRIBUTES.each do |field|
    value = attrs.key?(field) ? attrs[field] : attrs[field.to_sym]
    instance_variable_set("@#{field}", value)
  end
end

Class Method Details

.from_hash(hash) ⇒ Object



26
27
28
29
30
# File 'lib/voiceml/models/calls.rb', line 26

def self.from_hash(hash)
  return nil if hash.nil?

  new(hash)
end