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, enqueued_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.



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

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,
               enqueued_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
  @enqueued_time = enqueued_time unless enqueued_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)


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

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)


87
88
89
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 87

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)


78
79
80
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 78

def end_time
  @end_time
end

#enqueued_timeDateTime

Returns:

  • (DateTime)


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

def enqueued_time
  @enqueued_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)


105
106
107
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 105

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)


96
97
98
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 96

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)


114
115
116
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 114

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.



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
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 216

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
  enqueued_time = if hash.key?('enqueuedTime')
                    (DateTimeHelper.from_rfc3339(hash['enqueuedTime']) if hash['enqueuedTime'])
                  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,
                enqueued_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.



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

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['enqueued_time'] = 'enqueuedTime'
  @_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



165
166
167
168
169
170
171
172
173
174
175
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 165

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

#optionalsObject

An array for optional fields



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 141

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

#to_answer_timeObject



289
290
291
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 289

def to_answer_time
  DateTimeHelper.to_rfc3339(answer_time)
end

#to_end_timeObject



293
294
295
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 293

def to_end_time
  DateTimeHelper.to_rfc3339(end_time)
end

#to_enqueued_timeObject



285
286
287
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 285

def to_enqueued_time
  DateTimeHelper.to_rfc3339(enqueued_time)
end

#to_last_updateObject



297
298
299
# File 'lib/bandwidth/voice_lib/voice/models/call_state.rb', line 297

def to_last_update
  DateTimeHelper.to_rfc3339(last_update)
end

#to_start_timeObject



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

def to_start_time
  DateTimeHelper.to_rfc3339(start_time)
end