Class: VoiceCallService::VoiceCallService

Inherits:
AuthenticatedService show all
Defined in:
lib/voice_call_service/voice_call_service.rb

Overview

Establish voice calls between two participants See also: www.developergarden.com/openapi/dokumentation/services#4.2.1.

Constant Summary collapse

@@VOICE_CALL_SERVICE_ENDPOINT =
{
        :uri => "https://gateway.developer.telekom.com/p3gw-mod-odg-voicebutler/services/VoiceButlerService",
        :version => 1
}

Instance Method Summary collapse

Methods inherited from AuthenticatedService

#initialize, #invoke_authenticated

Methods inherited from BasicService

#initialize

Constructor Details

This class inherits a constructor from AuthenticatedService

Instance Method Details

#call_status(session_id, environment = ServiceEnvironment.MOCK, keep_alive = 1) ⇒ Object

Retrieve information about a specific call.

Parameters

session_id

Session id of the call of interest.

environment

Service environment as defined in ServiceEnvironment.

keep_alive

Prevent an expiration of the call by calling call_status with keep_alive = 1.



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/voice_call_service/voice_call_service.rb', line 60

def call_status(session_id, environment = ServiceEnvironment.MOCK, keep_alive = 1)
  response = invoke_authenticated("callStatus") do |message, doc|
    message.add("request")
    request = message.find("request")
    request.add('environment', environment)
    request.add('keepAlive', keep_alive)
    request.add('sessionId', session_id)
  end

  return CallStatusResponse.new(response)
end

#new_call(a_number, b_number, expiration, max_duration, environment = ServiceEnvironment.MOCK, privacy_a = false, privacy_b = false, greeter = "", account = "") ⇒ Object

Establish a voice call between two participants. After a connection to the first participant has been successfully established the seccond particiant is called. The call is established after the 2nd participant has picked up.

Parameters

a_number

Phone number of participant a.

b_number

Phone number of participant b.

expiration

Nr of seconds until the call will be canceled if no call_status call is received.

max_duration

Maximum duration of the call in secons. In addition to this the system limit is applied.

environment

Service environment as defined in ServiceLevel.

privacy_a

Whether to show the phone number of participant a.

privacy_b

Whether to show the phone number of participant b.

greeter

Currently unused

account

Currently unused



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/voice_call_service/voice_call_service.rb', line 37

def new_call(a_number, b_number, expiration, max_duration, environment = ServiceEnvironment.MOCK, privacy_a = false, privacy_b = false, greeter = "",  = "")
  response = invoke_authenticated("newCall") do |message, doc|
    message.add("request")
    request = message.find("request")
    request.add('environment', environment)
    request.add('aNumber', a_number)
    request.add('bNumber', b_number)
    request.add('privacyA', privacy_a.to_s)
    request.add('privacyB', privacy_b.to_s)
    request.add('expiration', expiration)
    request.add('maxDuration', max_duration)
    request.add('greeter', greeter)
    request.add('account', )
  end

  return VoiceCallResponse.new(response)
end

#new_call_sequenced(a_number, b_number, expiration, max_duration, environment = ServiceEnvironment.MOCK, privacy_a = false, privacy_b = false, max_wait = 60, greeter = "", account = "") ⇒ Object

Establishes a voice call similar to newCall. b_number can be an array of numbers. The service will call participants listed in b_number in sequence until sb. picks up.

Parameters

a_number

Phone number of participant a.

b_number

Phone number(s) of participant b. b_number can be an array of strings

representing numbers or a single string representing a single number.
expiration

Nr of seconds until the call will be canceled if no call_status with keepalive=true call is received.

max_duration

Maximum duration of the call in secons. In addition to this the system limit is applied.

environment

Service environment as defined in ServiceEnvironment.

privacy_a

Whether to show the phone number of participant a.

privacy_b

Whether to show the phone number of participant b.

max_wait

Call the next participant after max_wait seconds.

greeter

Currently unused.

account

Currently unused.



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/voice_call_service/voice_call_service.rb', line 106

def new_call_sequenced(a_number, b_number, expiration, max_duration, environment = ServiceEnvironment.MOCK, privacy_a = false, privacy_b = false, max_wait = 60, greeter = "",  = "")
  response = invoke_authenticated("newCallSequenced") do |message, doc|
    message.add("request")
    request = message.find("request")
    request.add('environment', environment)
    request.add('aNumber', a_number)

    # b_number can be an array of strings representing numbers or a single string representing a single number.
    if b_number.is_a? Array then
      # It's an array
      for bn in b_number do
        request.add('bNumber', bn)
      end
    else

      # We assume its a string
      request.add('bNumber', b_number)
    end

    request.add('privacyA', privacy_a.to_s)
    request.add('privacyB', privacy_b.to_s)
    request.add('expiration', expiration)
    request.add('maxDuration', max_duration)
    request.add('maxWait', max_wait)
    request.add('greeter', greeter)
    request.add('account', )
  end

  return VoiceCallResponse.new(response)
end

#teardown_call(session_id, environment = ServiceEnvironment.MOCK) ⇒ Object

Cancels an ongoing call.

Parameters

session_id
environment

Service environment as defined in ServiceEnvironment.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/voice_call_service/voice_call_service.rb', line 76

def teardown_call(session_id, environment = ServiceEnvironment.MOCK)
  response = invoke_authenticated("tearDownCall") do |message, doc|

    # Add namespace
    tdc = message.find("tearDownCall")
    tdc.set_attr("xmlns", "http://webservice.voicebutler.odg.tonline.de")

    message.add("request")
    request = message.find("request")
    request.add('environment', environment)
    request.add('sessionId', session_id)
  end

  return CallStatusResponse.new(response)
end