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, stir_shaken = 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.



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

def initialize(call_id = nil,
               parent_call_id = nil,
               application_id = nil,
                = nil,
               to = nil,
               from = nil,
               direction = nil,
               state = nil,
               identity = nil,
               stir_shaken = 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 unless call_id == SKIP
  @parent_call_id = parent_call_id unless parent_call_id == SKIP
  @application_id = application_id unless application_id == SKIP
  @account_id =  unless  == SKIP
  @to = to unless to == SKIP
  @from = from unless from == SKIP
  @direction = direction unless direction == SKIP
  @state = state unless state == SKIP
  @identity = identity unless identity == SKIP
  @stir_shaken = stir_shaken unless stir_shaken == SKIP
  @start_time = start_time unless start_time == SKIP
  @answer_time = answer_time unless answer_time == SKIP
  @end_time = end_time unless end_time == SKIP
  @disconnect_cause = disconnect_cause unless disconnect_cause == SKIP
  @error_message = error_message unless error_message == SKIP
  @error_id = error_id unless error_id == SKIP
  @last_update = last_update unless last_update == SKIP
end

Instance Attribute Details

#account_idString

TODO: Write general description for this method

Returns:

  • (String)


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

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)


69
70
71
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 69

def answer_time
  @answer_time
end

#application_idString

TODO: Write general description for this method

Returns:

  • (String)


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

def application_id
  @application_id
end

#call_idString

TODO: Write general description for this method

Returns:

  • (String)


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

def call_id
  @call_id
end

#directionString

TODO: Write general description for this method

Returns:

  • (String)


39
40
41
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 39

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)


84
85
86
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 84

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)


75
76
77
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 75

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)


102
103
104
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 102

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)


93
94
95
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 93

def error_message
  @error_message
end

#fromString

TODO: Write general description for this method

Returns:

  • (String)


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

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)


51
52
53
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 51

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)


111
112
113
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 111

def last_update
  @last_update
end

#parent_call_idString

TODO: Write general description for this method

Returns:

  • (String)


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

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)


63
64
65
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 63

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)


45
46
47
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 45

def state
  @state
end

#stir_shakenHash

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)


57
58
59
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 57

def stir_shaken
  @stir_shaken
end

#toString

TODO: Write general description for this method

Returns:

  • (String)


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

def to
  @to
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 209

def self.from_hash(hash)
  return nil unless hash

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

  # Create object from extracted values.
  CallState.new(call_id,
                parent_call_id,
                application_id,
                ,
                to,
                from,
                direction,
                state,
                identity,
                stir_shaken,
                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.



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

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['stir_shaken'] = 'stirShaken'
  @_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

#nullablesObject

An array for nullable fields



160
161
162
163
164
165
166
167
168
169
170
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 160

def nullables
  %w[
    parent_call_id
    identity
    answer_time
    end_time
    disconnect_cause
    error_message
    error_id
  ]
end

#optionalsObject

An array for optional fields



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 137

def optionals
  %w[
    call_id
    parent_call_id
    application_id
    account_id
    to
    from
    direction
    state
    identity
    stir_shaken
    start_time
    answer_time
    end_time
    disconnect_cause
    error_message
    error_id
    last_update
  ]
end

#to_answer_timeObject



272
273
274
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 272

def to_answer_time
  DateTimeHelper.to_rfc3339(answer_time)
end

#to_end_timeObject



276
277
278
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 276

def to_end_time
  DateTimeHelper.to_rfc3339(end_time)
end

#to_last_updateObject



280
281
282
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 280

def to_last_update
  DateTimeHelper.to_rfc3339(last_update)
end

#to_start_timeObject



268
269
270
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 268

def to_start_time
  DateTimeHelper.to_rfc3339(start_time)
end