Class: Bandwidth::CallState

Inherits:
Object
  • Object
show all
Defined in:
lib/bandwidth-sdk/models/call_state.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ CallState

Initializes the object

Parameters:

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

    Model attributes in the form of hash



164
165
166
167
168
169
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
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
# File 'lib/bandwidth-sdk/models/call_state.rb', line 164

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CallState` initialize method'
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CallState`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'application_id')
    self.application_id = attributes[:'application_id']
  end

  if attributes.key?(:'account_id')
    self. = attributes[:'account_id']
  end

  if attributes.key?(:'call_id')
    self.call_id = attributes[:'call_id']
  end

  if attributes.key?(:'parent_call_id')
    self.parent_call_id = attributes[:'parent_call_id']
  end

  if attributes.key?(:'to')
    self.to = attributes[:'to']
  end

  if attributes.key?(:'from')
    self.from = attributes[:'from']
  end

  if attributes.key?(:'direction')
    self.direction = attributes[:'direction']
  end

  if attributes.key?(:'state')
    self.state = attributes[:'state']
  end

  if attributes.key?(:'stir_shaken')
    if (value = attributes[:'stir_shaken']).is_a?(Hash)
      self.stir_shaken = value
    end
  end

  if attributes.key?(:'identity')
    self.identity = attributes[:'identity']
  end

  if attributes.key?(:'enqueued_time')
    self.enqueued_time = attributes[:'enqueued_time']
  end

  if attributes.key?(:'start_time')
    self.start_time = attributes[:'start_time']
  end

  if attributes.key?(:'answer_time')
    self.answer_time = attributes[:'answer_time']
  end

  if attributes.key?(:'end_time')
    self.end_time = attributes[:'end_time']
  end

  if attributes.key?(:'disconnect_cause')
    self.disconnect_cause = attributes[:'disconnect_cause']
  end

  if attributes.key?(:'error_message')
    self.error_message = attributes[:'error_message']
  end

  if attributes.key?(:'error_id')
    self.error_id = attributes[:'error_id']
  end

  if attributes.key?(:'last_update')
    self.last_update = attributes[:'last_update']
  end
end

Instance Attribute Details

#account_idObject

The account id associated with the call.



22
23
24
# File 'lib/bandwidth-sdk/models/call_state.rb', line 22

def 
  @account_id
end

#answer_timeObject

Populated once the call has been answered, with the time in ISO 8601 format.



54
55
56
# File 'lib/bandwidth-sdk/models/call_state.rb', line 54

def answer_time
  @answer_time
end

#application_idObject

The application id associated with the call.



19
20
21
# File 'lib/bandwidth-sdk/models/call_state.rb', line 19

def application_id
  @application_id
end

#call_idObject

The programmable voice API call ID.



25
26
27
# File 'lib/bandwidth-sdk/models/call_state.rb', line 25

def call_id
  @call_id
end

#directionObject

Returns the value of attribute direction.



36
37
38
# File 'lib/bandwidth-sdk/models/call_state.rb', line 36

def direction
  @direction
end

#disconnect_causeObject

| Cause | Description | |:——|:————| | ‘hangup`| One party hung up the call, a [`<Hangup>`](../../bxml/verbs/hangup.md) verb was executed, or there was no more BXML to execute; it indicates that the call ended normally. | | `busy` | Callee was busy. | | `timeout` | Call wasn’t answered before the ‘callTimeout` was reached. | | `cancel` | Call was cancelled by its originator while it was ringing. | | `rejected` | Call was rejected by the callee. | | `callback-error` | BXML callback couldn’t be delivered to your callback server. | | ‘invalid-bxml` | Invalid BXML was returned in response to a callback. | | `application-error` | An unsupported action was tried on the call, e.g. trying to play a .ogg audio. | | `account-limit` | Account rate limits were reached. | | `node-capacity-exceeded` | System maximum capacity was reached. | | `error` | Some error not described in any of the other causes happened on the call. | | `unknown` | Unknown error happened on the call. | Note: This list is not exhaustive and other values can appear in the future.



60
61
62
# File 'lib/bandwidth-sdk/models/call_state.rb', line 60

def disconnect_cause
  @disconnect_cause
end

#end_timeObject

Populated once the call has ended, with the time in ISO 8601 format.



57
58
59
# File 'lib/bandwidth-sdk/models/call_state.rb', line 57

def end_time
  @end_time
end

#enqueued_timeObject

The time this call was placed in queue.



48
49
50
# File 'lib/bandwidth-sdk/models/call_state.rb', line 48

def enqueued_time
  @enqueued_time
end

#error_idObject

Populated only if the call ended with an error, with a Bandwidth internal id that references the error event.



66
67
68
# File 'lib/bandwidth-sdk/models/call_state.rb', line 66

def error_id
  @error_id
end

#error_messageObject

Populated only if the call ended with an error, with text explaining the reason.



63
64
65
# File 'lib/bandwidth-sdk/models/call_state.rb', line 63

def error_message
  @error_message
end

#fromObject

The phone number that made the call, in E.164 format (e.g. +15555555555).



34
35
36
# File 'lib/bandwidth-sdk/models/call_state.rb', line 34

def from
  @from
end

#identityObject

The value of the ‘Identity` header from the inbound invite request. Only present for inbound calls and if the account is configured to forward this header.



45
46
47
# File 'lib/bandwidth-sdk/models/call_state.rb', line 45

def identity
  @identity
end

#last_updateObject

The last time the call had a state update, in ISO 8601 format.



69
70
71
# File 'lib/bandwidth-sdk/models/call_state.rb', line 69

def last_update
  @last_update
end

#parent_call_idObject

The A-leg call id, set only if this call is the B-leg of a [‘<Transfer>`](/docs/voice/bxml/transfer).



28
29
30
# File 'lib/bandwidth-sdk/models/call_state.rb', line 28

def parent_call_id
  @parent_call_id
end

#start_timeObject

The time the call was initiated, in ISO 8601 format. ‘null` if the call is still in your queue.



51
52
53
# File 'lib/bandwidth-sdk/models/call_state.rb', line 51

def start_time
  @start_time
end

#stateObject

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



39
40
41
# File 'lib/bandwidth-sdk/models/call_state.rb', line 39

def state
  @state
end

#stir_shakenObject

For inbound calls, the Bandwidth STIR/SHAKEN implementation will verify the information provided in the inbound invite request ‘Identity` header. The verification status is stored in the call state `stirShaken` property as follows. | Property | Description | |:——————|:————| | verstat | (optional) The verification status indicating whether the verification was successful or not. Possible values are `TN-Verification-Passed` or `TN-Verification-Failed`. | | attestationIndicator | (optional) The attestation level verified by Bandwidth. Possible values are `A` (full), `B` (partial) or `C` (gateway). | | originatingId | (optional) A unique origination identifier. | Note that these are common properties but that the `stirShaken` object is free form and can contain other key-value pairs. More information: [Understanding STIR/SHAKEN](www.bandwidth.com/regulations/stir-shaken).



42
43
44
# File 'lib/bandwidth-sdk/models/call_state.rb', line 42

def stir_shaken
  @stir_shaken
end

#toObject

The phone number that received the call, in E.164 format (e.g. +15555555555), or if the call was to a SIP URI, the SIP URI.



31
32
33
# File 'lib/bandwidth-sdk/models/call_state.rb', line 31

def to
  @to
end

Class Method Details

._deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'lib/bandwidth-sdk/models/call_state.rb', line 331

def self._deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = Bandwidth.const_get(type)
    klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



118
119
120
# File 'lib/bandwidth-sdk/models/call_state.rb', line 118

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/bandwidth-sdk/models/call_state.rb', line 94

def self.attribute_map
  {
    :'application_id' => :'applicationId',
    :'account_id' => :'accountId',
    :'call_id' => :'callId',
    :'parent_call_id' => :'parentCallId',
    :'to' => :'to',
    :'from' => :'from',
    :'direction' => :'direction',
    :'state' => :'state',
    :'stir_shaken' => :'stirShaken',
    :'identity' => :'identity',
    :'enqueued_time' => :'enqueuedTime',
    :'start_time' => :'startTime',
    :'answer_time' => :'answerTime',
    :'end_time' => :'endTime',
    :'disconnect_cause' => :'disconnectCause',
    :'error_message' => :'errorMessage',
    :'error_id' => :'errorId',
    :'last_update' => :'lastUpdate'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/bandwidth-sdk/models/call_state.rb', line 307

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/bandwidth-sdk/models/call_state.rb', line 147

def self.openapi_nullable
  Set.new([
    :'parent_call_id',
    :'stir_shaken',
    :'identity',
    :'enqueued_time',
    :'start_time',
    :'answer_time',
    :'end_time',
    :'disconnect_cause',
    :'error_message',
    :'error_id',
  ])
end

.openapi_typesObject

Attribute type mapping.



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/bandwidth-sdk/models/call_state.rb', line 123

def self.openapi_types
  {
    :'application_id' => :'String',
    :'account_id' => :'String',
    :'call_id' => :'String',
    :'parent_call_id' => :'String',
    :'to' => :'String',
    :'from' => :'String',
    :'direction' => :'CallDirectionEnum',
    :'state' => :'String',
    :'stir_shaken' => :'Hash<String, String>',
    :'identity' => :'String',
    :'enqueued_time' => :'Time',
    :'start_time' => :'Time',
    :'answer_time' => :'Time',
    :'end_time' => :'Time',
    :'disconnect_cause' => :'String',
    :'error_message' => :'String',
    :'error_id' => :'String',
    :'last_update' => :'Time'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'lib/bandwidth-sdk/models/call_state.rb', line 269

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      application_id == o.application_id &&
       == o. &&
      call_id == o.call_id &&
      parent_call_id == o.parent_call_id &&
      to == o.to &&
      from == o.from &&
      direction == o.direction &&
      state == o.state &&
      stir_shaken == o.stir_shaken &&
      identity == o.identity &&
      enqueued_time == o.enqueued_time &&
      start_time == o.start_time &&
      answer_time == o.answer_time &&
      end_time == o.end_time &&
      disconnect_cause == o.disconnect_cause &&
      error_message == o.error_message &&
      error_id == o.error_id &&
      last_update == o.last_update
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



402
403
404
405
406
407
408
409
410
411
412
413
414
# File 'lib/bandwidth-sdk/models/call_state.rb', line 402

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


294
295
296
# File 'lib/bandwidth-sdk/models/call_state.rb', line 294

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



300
301
302
# File 'lib/bandwidth-sdk/models/call_state.rb', line 300

def hash
  [application_id, , call_id, parent_call_id, to, from, direction, state, stir_shaken, identity, enqueued_time, start_time, answer_time, end_time, disconnect_cause, error_message, error_id, last_update].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



254
255
256
257
258
# File 'lib/bandwidth-sdk/models/call_state.rb', line 254

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



378
379
380
# File 'lib/bandwidth-sdk/models/call_state.rb', line 378

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



384
385
386
387
388
389
390
391
392
393
394
395
396
# File 'lib/bandwidth-sdk/models/call_state.rb', line 384

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



372
373
374
# File 'lib/bandwidth-sdk/models/call_state.rb', line 372

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



262
263
264
265
# File 'lib/bandwidth-sdk/models/call_state.rb', line 262

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  true
end