Class: Bandwidth::CallState

Inherits:
BaseModel show all
Defined in:
lib/bandwidth/voice_lib/voice/models/call_state.rb

Overview

CallState Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(call_id = nil, parent_call_id = nil, application_id = nil, account_id = nil, to = nil, from = nil, direction = nil, state = nil, identity = nil, pai = nil, start_time = nil, answer_time = nil, end_time = nil, disconnect_cause = nil, error_message = nil, error_id = nil, last_update = nil) ⇒ CallState

Returns a new instance of CallState.



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
166
167
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 133

def initialize(call_id = nil,
               parent_call_id = nil,
               application_id = nil,
                = nil,
               to = nil,
               from = nil,
               direction = nil,
               state = nil,
               identity = nil,
               pai = nil,
               start_time = nil,
               answer_time = nil,
               end_time = nil,
               disconnect_cause = nil,
               error_message = nil,
               error_id = nil,
               last_update = nil)
  @call_id = call_id
  @parent_call_id = parent_call_id
  @application_id = application_id
  @account_id = 
  @to = to
  @from = from
  @direction = direction
  @state = state
  @identity = identity
  @pai = pai
  @start_time = start_time
  @answer_time = answer_time
  @end_time = end_time
  @disconnect_cause = disconnect_cause
  @error_message = error_message
  @error_id = error_id
  @last_update = last_update
end

Instance Attribute Details

#account_idString

TODO: Write general description for this method

Returns:

  • (String)


24
25
26
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 24

def 
  @account_id
end

#answer_timeDateTime

The current state of the call. Current possible values are ‘initiated’, ‘answered’ and ‘disconnected’. Additional states may be added in the future, so your application must be tolerant of unknown values.

Returns:

  • (DateTime)


66
67
68
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 66

def answer_time
  @answer_time
end

#application_idString

TODO: Write general description for this method

Returns:

  • (String)


20
21
22
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 20

def application_id
  @application_id
end

#call_idString

TODO: Write general description for this method

Returns:

  • (String)


12
13
14
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 12

def call_id
  @call_id
end

#directionString

TODO: Write general description for this method

Returns:

  • (String)


36
37
38
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 36

def direction
  @direction
end

#disconnect_causeString

The reason the call was disconnected, or null if the call is still active. Current values are ‘cancel’, ‘timeout’, ‘busy’, ‘rejected’, ‘hangup’, ‘invalid-bxml’, ‘callback-error’, ‘application-error’, ‘error’, ‘account-limit’, ‘node-capacity-exceeded’ and ‘unknown’. Additional causes may be added in the future, so your application must be tolerant of unknown values.

Returns:

  • (String)


81
82
83
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 81

def disconnect_cause
  @disconnect_cause
end

#end_timeDateTime

The current state of the call. Current possible values are ‘initiated’, ‘answered’ and ‘disconnected’. Additional states may be added in the future, so your application must be tolerant of unknown values.

Returns:

  • (DateTime)


72
73
74
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 72

def end_time
  @end_time
end

#error_idString

The reason the call was disconnected, or null if the call is still active. Current values are ‘cancel’, ‘timeout’, ‘busy’, ‘rejected’, ‘hangup’, ‘invalid-bxml’, ‘callback-error’, ‘application-error’, ‘error’, ‘account-limit’, ‘node-capacity-exceeded’ and ‘unknown’. Additional causes may be added in the future, so your application must be tolerant of unknown values.

Returns:

  • (String)


99
100
101
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 99

def error_id
  @error_id
end

#error_messageString

The reason the call was disconnected, or null if the call is still active. Current values are ‘cancel’, ‘timeout’, ‘busy’, ‘rejected’, ‘hangup’, ‘invalid-bxml’, ‘callback-error’, ‘application-error’, ‘error’, ‘account-limit’, ‘node-capacity-exceeded’ and ‘unknown’. Additional causes may be added in the future, so your application must be tolerant of unknown values.

Returns:

  • (String)


90
91
92
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 90

def error_message
  @error_message
end

#fromString

TODO: Write general description for this method

Returns:

  • (String)


32
33
34
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 32

def from
  @from
end

#identityString

The current state of the call. Current possible values are ‘initiated’, ‘answered’ and ‘disconnected’. Additional states may be added in the future, so your application must be tolerant of unknown values.

Returns:

  • (String)


48
49
50
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 48

def identity
  @identity
end

#last_updateDateTime

The reason the call was disconnected, or null if the call is still active. Current values are ‘cancel’, ‘timeout’, ‘busy’, ‘rejected’, ‘hangup’, ‘invalid-bxml’, ‘callback-error’, ‘application-error’, ‘error’, ‘account-limit’, ‘node-capacity-exceeded’ and ‘unknown’. Additional causes may be added in the future, so your application must be tolerant of unknown values.

Returns:

  • (DateTime)


108
109
110
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 108

def last_update
  @last_update
end

#paiHash

The current state of the call. Current possible values are ‘initiated’, ‘answered’ and ‘disconnected’. Additional states may be added in the future, so your application must be tolerant of unknown values.

Returns:

  • (Hash)


54
55
56
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 54

def pai
  @pai
end

#parent_call_idString

TODO: Write general description for this method

Returns:

  • (String)


16
17
18
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 16

def parent_call_id
  @parent_call_id
end

#start_timeDateTime

The current state of the call. Current possible values are ‘initiated’, ‘answered’ and ‘disconnected’. Additional states may be added in the future, so your application must be tolerant of unknown values.

Returns:

  • (DateTime)


60
61
62
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 60

def start_time
  @start_time
end

#stateString

The current state of the call. Current possible values are ‘initiated’, ‘answered’ and ‘disconnected’. Additional states may be added in the future, so your application must be tolerant of unknown values.

Returns:

  • (String)


42
43
44
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 42

def state
  @state
end

#toString

TODO: Write general description for this method

Returns:

  • (String)


28
29
30
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 28

def to
  @to
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 170

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  call_id = hash['callId']
  parent_call_id = hash['parentCallId']
  application_id = hash['applicationId']
   = hash['accountId']
  to = hash['to']
  from = hash['from']
  direction = hash['direction']
  state = hash['state']
  identity = hash['identity']
  pai = hash['pai']
  start_time = DateTimeHelper.from_rfc3339(hash['startTime']) if
    hash['startTime']
  answer_time = DateTimeHelper.from_rfc3339(hash['answerTime']) if
    hash['answerTime']
  end_time = DateTimeHelper.from_rfc3339(hash['endTime']) if
    hash['endTime']
  disconnect_cause = hash['disconnectCause']
  error_message = hash['errorMessage']
  error_id = hash['errorId']
  last_update = DateTimeHelper.from_rfc3339(hash['lastUpdate']) if
    hash['lastUpdate']

  # Create object from extracted values.
  CallState.new(call_id,
                parent_call_id,
                application_id,
                ,
                to,
                from,
                direction,
                state,
                identity,
                pai,
                start_time,
                answer_time,
                end_time,
                disconnect_cause,
                error_message,
                error_id,
                last_update)
end

.namesObject

A mapping from model property names to API property names.



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 111

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['call_id'] = 'callId'
  @_hash['parent_call_id'] = 'parentCallId'
  @_hash['application_id'] = 'applicationId'
  @_hash['account_id'] = 'accountId'
  @_hash['to'] = 'to'
  @_hash['from'] = 'from'
  @_hash['direction'] = 'direction'
  @_hash['state'] = 'state'
  @_hash['identity'] = 'identity'
  @_hash['pai'] = 'pai'
  @_hash['start_time'] = 'startTime'
  @_hash['answer_time'] = 'answerTime'
  @_hash['end_time'] = 'endTime'
  @_hash['disconnect_cause'] = 'disconnectCause'
  @_hash['error_message'] = 'errorMessage'
  @_hash['error_id'] = 'errorId'
  @_hash['last_update'] = 'lastUpdate'
  @_hash
end

Instance Method Details

#to_answer_timeObject



220
221
222
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 220

def to_answer_time
  DateTimeHelper.to_rfc3339(answer_time)
end

#to_end_timeObject



224
225
226
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 224

def to_end_time
  DateTimeHelper.to_rfc3339(end_time)
end

#to_last_updateObject



228
229
230
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 228

def to_last_update
  DateTimeHelper.to_rfc3339(last_update)
end

#to_start_timeObject



216
217
218
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 216

def to_start_time
  DateTimeHelper.to_rfc3339(start_time)
end