Class: Verizon::GeoFenceConfigurationResponse

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

Overview

Response for /api/v1/application/configurations/geofence endpoint. It provides a response if the configuration was created and saved in the system.

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(id = nil, vendor_id = nil, geo_fence = nil, message_standard = MessageStandardEnum::SAE, messages = nil, is_active = nil, name = SKIP, description = SKIP) ⇒ GeoFenceConfigurationResponse

Returns a new instance of GeoFenceConfigurationResponse.



90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/verizon/models/geo_fence_configuration_response.rb', line 90

def initialize(id = nil, vendor_id = nil, geo_fence = nil,
               message_standard = MessageStandardEnum::SAE, messages = nil,
               is_active = nil, name = SKIP, description = SKIP)
  @id = id
  @vendor_id = vendor_id
  @name = name unless name == SKIP
  @description = description unless description == SKIP
  @geo_fence = geo_fence
  @message_standard = message_standard
  @messages = messages
  @is_active = is_active
end

Instance Attribute Details

#descriptionString

Description of the configuration.

Returns:

  • (String)


29
30
31
# File 'lib/verizon/models/geo_fence_configuration_response.rb', line 29

def description
  @description
end

#geo_fenceEtxGeoFence

The GeoJSON representation of geofence. Geofence supports the following geometry types: LineString, Polygon, MultiLineString, and MultiPolygon. The system only supports a single Feature in the FeatureCollection, so only one Line, Polygon, MultiLine or MultiPolygon can be defined within one Geofencing configuration.

Returns:



37
38
39
# File 'lib/verizon/models/geo_fence_configuration_response.rb', line 37

def geo_fence
  @geo_fence
end

#idString

The generated ID (UUID v4) for the configuration. It has to be used when asking for changing any of the configuration parameters.

Returns:

  • (String)


17
18
19
# File 'lib/verizon/models/geo_fence_configuration_response.rb', line 17

def id
  @id
end

#is_activeTrueClass | FalseClass

List of predefined messages that belongs to the geofence. These are the messages that are sent out by the system when the Trigger Condition for the message is met.

Returns:

  • (TrueClass | FalseClass)


61
62
63
# File 'lib/verizon/models/geo_fence_configuration_response.rb', line 61

def is_active
  @is_active
end

#message_standardMessageStandardEnum

Select which V2X messaging standard will be used for the message generation. The following options are supported:

- "etsi": The message will be generated using the ETSI (European)

standard (e.g. DENM).

- "sae": The message will be generated using the SAE J2735 (North

American) standard (e.g. RSA, TIM).

- if not sent while POST, defaults to "sae"
- mandatory to send "etsi" standard here, if ETSI messages are being

sent in config

Returns:



49
50
51
# File 'lib/verizon/models/geo_fence_configuration_response.rb', line 49

def message_standard
  @message_standard
end

#messagesArray[Object]

List of predefined messages that belongs to the geofence. These are the messages that are sent out by the system when the Trigger Condition for the message is met.

Returns:

  • (Array[Object])


55
56
57
# File 'lib/verizon/models/geo_fence_configuration_response.rb', line 55

def messages
  @messages
end

#nameString

Name of the configuration.

Returns:

  • (String)


25
26
27
# File 'lib/verizon/models/geo_fence_configuration_response.rb', line 25

def name
  @name
end

#vendor_idString

The vendor that the configuration belongs to.

Returns:

  • (String)


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

def vendor_id
  @vendor_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/verizon/models/geo_fence_configuration_response.rb', line 104

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  vendor_id = hash.key?('vendorId') ? hash['vendorId'] : nil
  geo_fence = EtxGeoFence.from_hash(hash['geoFence']) if hash['geoFence']
  message_standard = hash['messageStandard'] ||= MessageStandardEnum::SAE
  messages = hash.key?('messages') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:Message4), hash['messages']
  ) : nil
  is_active = hash.key?('isActive') ? hash['isActive'] : nil
  name = hash.key?('name') ? hash['name'] : SKIP
  description = hash.key?('description') ? hash['description'] : SKIP

  # Create object from extracted values.
  GeoFenceConfigurationResponse.new(id,
                                    vendor_id,
                                    geo_fence,
                                    message_standard,
                                    messages,
                                    is_active,
                                    name,
                                    description)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['vendor_id'] = 'vendorId'
  @_hash['name'] = 'name'
  @_hash['description'] = 'description'
  @_hash['geo_fence'] = 'geoFence'
  @_hash['message_standard'] = 'messageStandard'
  @_hash['messages'] = 'messages'
  @_hash['is_active'] = 'isActive'
  @_hash
end

.nullablesObject

An array for nullable fields



86
87
88
# File 'lib/verizon/models/geo_fence_configuration_response.rb', line 86

def self.nullables
  []
end

.optionalsObject

An array for optional fields



78
79
80
81
82
83
# File 'lib/verizon/models/geo_fence_configuration_response.rb', line 78

def self.optionals
  %w[
    name
    description
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



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
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/verizon/models/geo_fence_configuration_response.rb', line 132

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.id,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.vendor_id,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.geo_fence,
                              ->(val) { EtxGeoFence.validate(val) },
                              is_model_hash: true) and
        APIHelper.valid_type?(value.message_standard,
                              ->(val) { MessageStandardEnum.validate(val) }) and
        UnionTypeLookUp.get(:Message4)
                       .validate(value.messages) and
        APIHelper.valid_type?(value.is_active,
                              ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['id'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['vendorId'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['geoFence'],
                            ->(val) { EtxGeoFence.validate(val) },
                            is_model_hash: true) and
      APIHelper.valid_type?(value['messageStandard'],
                            ->(val) { MessageStandardEnum.validate(val) }) and
      UnionTypeLookUp.get(:Message4)
                     .validate(value['messages']) and
      APIHelper.valid_type?(value['isActive'],
                            ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



179
180
181
182
183
184
185
# File 'lib/verizon/models/geo_fence_configuration_response.rb', line 179

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, vendor_id: #{@vendor_id.inspect}, name:"\
  " #{@name.inspect}, description: #{@description.inspect}, geo_fence: #{@geo_fence.inspect},"\
  " message_standard: #{@message_standard.inspect}, messages: #{@messages.inspect}, is_active:"\
  " #{@is_active.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



171
172
173
174
175
176
# File 'lib/verizon/models/geo_fence_configuration_response.rb', line 171

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, vendor_id: #{@vendor_id}, name: #{@name}, description:"\
  " #{@description}, geo_fence: #{@geo_fence}, message_standard: #{@message_standard},"\
  " messages: #{@messages}, is_active: #{@is_active}>"
end