Class: Punchblock::Component::Tropo::Transfer

Inherits:
ComponentNode show all
Includes:
HasHeaders
Defined in:
lib/punchblock/component/tropo/transfer.rb

Defined Under Namespace

Classes: Complete, Ring

Instance Attribute Summary

Attributes inherited from ComponentNode

#complete_event

Attributes inherited from RayoNode

#call_id, #client, #component_id, #connection, #original_component

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasHeaders

#headers, #headers=, #headers_hash

Methods inherited from ComponentNode

#add_event, #initialize, #register_event_handler, #register_initial_handlers, #response=, #stop!, #stop_action, #write_action

Methods inherited from Punchblock::CommandNode

#initialize, #response, #response=, #write_attr

Methods inherited from RayoNode

class_from_registration, #eql?, import, #inspect, register, #source

Constructor Details

This class inherits a constructor from Punchblock::Component::ComponentNode

Class Method Details

.new(options = {}) ⇒ Message::Transfer

Creates an Rayo transfer command

Examples:

Transfer.new(:to => 'sip:[email protected]', :from => 'sip:[email protected]', :terminator => '#').to_xml

returns:
  <transfer xmlns="urn:xmpp:tropo:transfer:1" from="sip:[email protected]" terminator="#">
    <to>sip:[email protected]</to>
  </transfer>

Parameters:

  • options (Hash) (defaults to: {})

    for transferring a call

Options Hash (options):

  • :to (String, Array[String])

    The destination(s) for the call transfer (ie - tel:+14155551212 or sip:[email protected]). Can be an array to hunt.

  • :from (String)

    The caller ID for the call transfer (ie - tel:+14155551212 or sip:[email protected])

  • :terminator (String, Optional)

    The string key press required to abort the transfer.

  • :timeout (Integer, Optional)

    How long to wait - in seconds - for an answer, busy signal, or other event to occur.

  • :answer_on_media (Boolean, Optional)

    If set to true, the call will be considered “answered” and audio will begin playing as soon as media is received from the far end (ringing / busy signal / etc)

  • :media (Symbol, Optional)

    Rules for handling media. Can be :direct, where parties negotiate media directly, or :bridge where the media server will bridge audio, allowing media features like recording and ASR.

  • :ring (Ring, Hash, Optional)

    to play to the caller untill connected

Returns:

  • (Message::Transfer)

    an Rayo “transfer” message



31
32
33
34
35
# File 'lib/punchblock/component/tropo/transfer.rb', line 31

def self.new(options = {})
  super().tap do |new_node|
    options.each_pair { |k,v| new_node.send :"#{k}=", v }
  end
end

Instance Method Details

#answer_on_mediaBoolean

Returns If true, the call will be considered “answered” and audio will begin playing as soon as media is received from the far end (ringing / busy signal / etc).

Returns:

  • (Boolean)

    If true, the call will be considered “answered” and audio will begin playing as soon as media is received from the far end (ringing / busy signal / etc)



103
104
105
# File 'lib/punchblock/component/tropo/transfer.rb', line 103

def answer_on_media
  read_attr('answer-on-media') == 'true'
end

#answer_on_media=(aom) ⇒ Object

Parameters:

  • aom (Boolean)

    If set to true, the call will be considered “answered” and audio will begin playing as soon as media is received from the far end (ringing / busy signal / etc)



110
111
112
# File 'lib/punchblock/component/tropo/transfer.rb', line 110

def answer_on_media=(aom)
  write_attr 'answer-on-media', aom.to_s
end

#fromString

Returns The caller ID for the call transfer.

Returns:

  • (String)

    The caller ID for the call transfer



61
62
63
# File 'lib/punchblock/component/tropo/transfer.rb', line 61

def from
  read_attr :from
end

#from=(transfer_from) ⇒ Object

Parameters:

  • :to (String, Array[String])

    The destination(s) for the call transfer (ie - tel:+14155551212 or sip:[email protected]). Can be an array to hunt.



68
69
70
# File 'lib/punchblock/component/tropo/transfer.rb', line 68

def from=(transfer_from)
  write_attr :from, transfer_from
end

#inspect_attributesObject

:nodoc:



150
151
152
# File 'lib/punchblock/component/tropo/transfer.rb', line 150

def inspect_attributes # :nodoc:
  [:to, :from, :terminator, :timeout, :answer_on_media] + super
end

#mediaSymbol

Returns Rules for handling media. Can be :direct, where parties negotiate media directly, or :bridge where the media server will bridge audio, allowing media features like recording and ASR.

Returns:

  • (Symbol)

    Rules for handling media. Can be :direct, where parties negotiate media directly, or :bridge where the media server will bridge audio, allowing media features like recording and ASR.



117
118
119
# File 'lib/punchblock/component/tropo/transfer.rb', line 117

def media
  read_attr 'media', :to_sym
end

#media=(media) ⇒ Object

Parameters:

  • media (Symbol)

    Rules for handling media. Can be :direct, where parties negotiate media directly, or :bridge where the media server will bridge audio, allowing media features like recording and ASR.



124
125
126
# File 'lib/punchblock/component/tropo/transfer.rb', line 124

def media=(media)
  write_attr 'media', media
end

#ringRing

Returns the ringer to play to the caller while transferring.

Returns:

  • (Ring)

    the ringer to play to the caller while transferring



131
132
133
134
# File 'lib/punchblock/component/tropo/transfer.rb', line 131

def ring
  node = find_first '//ns:ring', :ns => self.registered_ns
  Ring.new node if node
end

#ring=(ring) ⇒ Object

Parameters:

Options Hash (ring):

  • :text (String)

    Text to speak to the caller as an announcement

  • :url (String)

    URL to play to the caller as an announcement



141
142
143
144
# File 'lib/punchblock/component/tropo/transfer.rb', line 141

def ring=(ring)
  ring = Ring.new(ring) unless ring.is_a?(Ring)
  self << ring
end

#terminatorString

Returns The string key press required to abort the transfer.

Returns:

  • (String)

    The string key press required to abort the transfer.



75
76
77
# File 'lib/punchblock/component/tropo/transfer.rb', line 75

def terminator
  read_attr :terminator
end

#terminator=(terminator) ⇒ Object

Parameters:

  • terminator (String)

    The string key press required to abort the transfer.



82
83
84
# File 'lib/punchblock/component/tropo/transfer.rb', line 82

def terminator=(terminator)
  write_attr :terminator, terminator
end

#timeoutInteger

Returns How long to wait - in seconds - for an answer, busy signal, or other event to occur.

Returns:

  • (Integer)

    How long to wait - in seconds - for an answer, busy signal, or other event to occur.



89
90
91
# File 'lib/punchblock/component/tropo/transfer.rb', line 89

def timeout
  read_attr :timeout, :to_i
end

#timeout=(timeout) ⇒ Object

Parameters:

  • timeout (Integer)

    How long to wait - in seconds - for an answer, busy signal, or other event to occur.



96
97
98
# File 'lib/punchblock/component/tropo/transfer.rb', line 96

def timeout=(timeout)
  write_attr :timeout, timeout
end

#toArray[String]

Returns The destination(s) for the call transfer.

Returns:

  • (Array[String])

    The destination(s) for the call transfer



40
41
42
# File 'lib/punchblock/component/tropo/transfer.rb', line 40

def to
  find('ns:to', :ns => self.class.registered_ns).map &:text
end

#to=(transfer_to) ⇒ Object

Parameters:

  • :to (String, Array[String])

    The destination(s) for the call transfer (ie - tel:+14155551212 or sip:[email protected]). Can be an array to hunt.



47
48
49
50
51
52
53
54
55
56
# File 'lib/punchblock/component/tropo/transfer.rb', line 47

def to=(transfer_to)
  find('//ns:to', :ns => self.class.registered_ns).each &:remove
  if transfer_to
    [transfer_to].flatten.each do |i|
      to = RayoNode.new :to
      to << i
      self << to
    end
  end
end