Class: Verizon::Message1
- Defined in:
- lib/verizon/models/message1.rb
Overview
Message1 Model.
Instance Attribute Summary collapse
-
#distribution_schedule ⇒ DistributionSchedule
The distribution schedule parameters for broadcast messages.
-
#distribution_type ⇒ Array[DistributionTypes]
Type of the distribution.
-
#is_private ⇒ TrueClass | FalseClass
Defines whether the message is private or public.
-
#limits ⇒ Array[Object]
List of limitations.
-
#road_user_type ⇒ Array[RoadUserTypes]
Type of the Road User.
-
#sae_alert ⇒ SaeAlert
The distribution schedule parameters for broadcast messages.
-
#trigger_conditions ⇒ Array[TriggerCondition]
Trigger conditions that define on which road user action the message will be sent.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(is_private:, road_user_type:, trigger_conditions:, sae_alert:, limits: SKIP, distribution_type: SKIP, distribution_schedule: SKIP, additional_properties: nil) ⇒ Message1
constructor
A new instance of Message1.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(is_private:, road_user_type:, trigger_conditions:, sae_alert:, limits: SKIP, distribution_type: SKIP, distribution_schedule: SKIP, additional_properties: nil) ⇒ Message1
Returns a new instance of Message1.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/verizon/models/message1.rb', line 75 def initialize(is_private:, road_user_type:, trigger_conditions:, sae_alert:, limits: SKIP, distribution_type: SKIP, distribution_schedule: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @is_private = is_private @road_user_type = road_user_type @trigger_conditions = trigger_conditions @limits = limits unless limits == SKIP @distribution_type = distribution_type unless distribution_type == SKIP @distribution_schedule = distribution_schedule unless distribution_schedule == SKIP @sae_alert = sae_alert @additional_properties = additional_properties end |
Instance Attribute Details
#distribution_schedule ⇒ DistributionSchedule
The distribution schedule parameters for broadcast messages.
42 43 44 |
# File 'lib/verizon/models/message1.rb', line 42 def distribution_schedule @distribution_schedule end |
#distribution_type ⇒ Array[DistributionTypes]
Type of the distribution.
38 39 40 |
# File 'lib/verizon/models/message1.rb', line 38 def distribution_type @distribution_type end |
#is_private ⇒ TrueClass | FalseClass
Defines whether the message is private or public. Private messages are published under the Vendor ID defined in the configuration and only visible to devices of selected vendors. Public messages are published under the Public vendor and are visible to all the users.
18 19 20 |
# File 'lib/verizon/models/message1.rb', line 18 def is_private @is_private end |
#limits ⇒ Array[Object]
List of limitations. These limitations can be used for making the trigger condition more precise by defining speed and motion direction requirements to be met before the messages are sent out.
34 35 36 |
# File 'lib/verizon/models/message1.rb', line 34 def limits @limits end |
#road_user_type ⇒ Array[RoadUserTypes]
Type of the Road User.
22 23 24 |
# File 'lib/verizon/models/message1.rb', line 22 def road_user_type @road_user_type end |
#sae_alert ⇒ SaeAlert
The distribution schedule parameters for broadcast messages.
46 47 48 |
# File 'lib/verizon/models/message1.rb', line 46 def sae_alert @sae_alert end |
#trigger_conditions ⇒ Array[TriggerCondition]
Trigger conditions that define on which road user action the message will be sent. If multiple Trigger Conditions are defined any of them will trigger the message.
28 29 30 |
# File 'lib/verizon/models/message1.rb', line 28 def trigger_conditions @trigger_conditions end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/verizon/models/message1.rb', line 92 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. is_private = hash.key?('isPrivate') ? hash['isPrivate'] : nil road_user_type = hash.key?('roadUserType') ? hash['roadUserType'] : nil trigger_conditions = hash.key?('triggerConditions') ? hash['triggerConditions'] : nil sae_alert = SaeAlert.from_hash(hash['saeAlert']) if hash['saeAlert'] limits = hash.key?('limits') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:Limits), hash['limits'] ) : SKIP distribution_type = hash.key?('distributionType') ? hash['distributionType'] : SKIP distribution_schedule = DistributionSchedule.from_hash(hash['distributionSchedule']) if hash['distributionSchedule'] # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. Message1.new(is_private: is_private, road_user_type: road_user_type, trigger_conditions: trigger_conditions, sae_alert: sae_alert, limits: limits, distribution_type: distribution_type, distribution_schedule: distribution_schedule, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/verizon/models/message1.rb', line 49 def self.names @_hash = {} if @_hash.nil? @_hash['is_private'] = 'isPrivate' @_hash['road_user_type'] = 'roadUserType' @_hash['trigger_conditions'] = 'triggerConditions' @_hash['limits'] = 'limits' @_hash['distribution_type'] = 'distributionType' @_hash['distribution_schedule'] = 'distributionSchedule' @_hash['sae_alert'] = 'saeAlert' @_hash end |
.nullables ⇒ Object
An array for nullable fields
71 72 73 |
# File 'lib/verizon/models/message1.rb', line 71 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
62 63 64 65 66 67 68 |
# File 'lib/verizon/models/message1.rb', line 62 def self.optionals %w[ limits distribution_type distribution_schedule ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
129 130 131 132 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 |
# File 'lib/verizon/models/message1.rb', line 129 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.is_private, ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass }) and APIHelper.valid_type?(value.road_user_type, ->(val) { RoadUserTypes.validate(val) }) and APIHelper.valid_type?(value.trigger_conditions, ->(val) { TriggerCondition.validate(val) }) and APIHelper.valid_type?(value.sae_alert, ->(val) { SaeAlert.validate(val) }, is_model_hash: true) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['isPrivate'], ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass }) and APIHelper.valid_type?(value['roadUserType'], ->(val) { RoadUserTypes.validate(val) }) and APIHelper.valid_type?(value['triggerConditions'], ->(val) { TriggerCondition.validate(val) }) and APIHelper.valid_type?(value['saeAlert'], ->(val) { SaeAlert.validate(val) }, is_model_hash: true) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
169 170 171 172 173 174 175 176 |
# File 'lib/verizon/models/message1.rb', line 169 def inspect class_name = self.class.name.split('::').last "<#{class_name} is_private: #{@is_private.inspect}, road_user_type:"\ " #{@road_user_type.inspect}, trigger_conditions: #{@trigger_conditions.inspect}, limits:"\ " #{@limits.inspect}, distribution_type: #{@distribution_type.inspect},"\ " distribution_schedule: #{@distribution_schedule.inspect}, sae_alert:"\ " #{@sae_alert.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
160 161 162 163 164 165 166 |
# File 'lib/verizon/models/message1.rb', line 160 def to_s class_name = self.class.name.split('::').last "<#{class_name} is_private: #{@is_private}, road_user_type: #{@road_user_type},"\ " trigger_conditions: #{@trigger_conditions}, limits: #{@limits}, distribution_type:"\ " #{@distribution_type}, distribution_schedule: #{@distribution_schedule}, sae_alert:"\ " #{@sae_alert}, additional_properties: #{@additional_properties}>" end |