Class: Verizon::DenmPayload

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/verizon/models/denm_payload.rb

Overview

The payload of the DENM PDU.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(management = nil, situation = SKIP) ⇒ DenmPayload

Returns a new instance of DenmPayload.



43
44
45
46
# File 'lib/verizon/models/denm_payload.rb', line 43

def initialize(management = nil, situation = SKIP)
  @management = management
  @situation = situation unless situation == SKIP
end

Instance Attribute Details

#managementManagement

This represent the management container describing the meta information about the event, such as the detection time, the event’s location, the source of the event, and the notification distance.

Returns:



16
17
18
# File 'lib/verizon/models/denm_payload.rb', line 16

def management
  @management
end

#situationSituation

This represents the situation container describing the event and the reliability of the detection source.

Returns:



21
22
23
# File 'lib/verizon/models/denm_payload.rb', line 21

def situation
  @situation
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/verizon/models/denm_payload.rb', line 49

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  management = Management.from_hash(hash['management']) if hash['management']
  situation = Situation.from_hash(hash['situation']) if hash['situation']

  # Create object from extracted values.
  DenmPayload.new(management,
                  situation)
end

.namesObject

A mapping from model property names to API property names.



24
25
26
27
28
29
# File 'lib/verizon/models/denm_payload.rb', line 24

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['management'] = 'management'
  @_hash['situation'] = 'situation'
  @_hash
end

.nullablesObject

An array for nullable fields



39
40
41
# File 'lib/verizon/models/denm_payload.rb', line 39

def self.nullables
  []
end

.optionalsObject

An array for optional fields



32
33
34
35
36
# File 'lib/verizon/models/denm_payload.rb', line 32

def self.optionals
  %w[
    situation
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (DenmPayload | Hash)

    value against the validation is performed.



63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/verizon/models/denm_payload.rb', line 63

def self.validate(value)
  if value.instance_of? self
    return APIHelper.valid_type?(value.management,
                                 ->(val) { Management.validate(val) },
                                 is_model_hash: true)
  end

  return false unless value.instance_of? Hash

  APIHelper.valid_type?(value['management'],
                        ->(val) { Management.validate(val) },
                        is_model_hash: true)
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



84
85
86
87
# File 'lib/verizon/models/denm_payload.rb', line 84

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} management: #{@management.inspect}, situation: #{@situation.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



78
79
80
81
# File 'lib/verizon/models/denm_payload.rb', line 78

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} management: #{@management}, situation: #{@situation}>"
end