Class: Samsara::Types::HealthResponseResponseBody

Inherits:
Object
  • Object
show all
Defined in:
lib/samsara_api/types/health_response_response_body.rb

Overview

Health information for the device.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(health_details: OMIT, health_reasons: OMIT, health_status: OMIT, primary_health_reason: OMIT, primary_health_reason_start_time: OMIT, recommended_action: OMIT, additional_properties: nil) ⇒ Samsara::Types::HealthResponseResponseBody

Parameters:

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/samsara_api/types/health_response_response_body.rb', line 221

def initialize(health_details: OMIT, health_reasons: OMIT, health_status: OMIT, primary_health_reason: OMIT, primary_health_reason_start_time: OMIT, recommended_action: OMIT, additional_properties: nil)
  @health_details = health_details if health_details != OMIT
  @health_reasons = health_reasons if health_reasons != OMIT
  @health_status = health_status if health_status != OMIT
  @primary_health_reason = primary_health_reason if primary_health_reason != OMIT
  @primary_health_reason_start_time = primary_health_reason_start_time if primary_health_reason_start_time != OMIT
  @recommended_action = recommended_action if recommended_action != OMIT
  @additional_properties = additional_properties
  @_field_set = { "healthDetails": health_details, "healthReasons": health_reasons, "healthStatus": health_status, "primaryHealthReason": primary_health_reason, "primaryHealthReasonStartTime": primary_health_reason_start_time, "recommendedAction": recommended_action }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



117
118
119
# File 'lib/samsara_api/types/health_response_response_body.rb', line 117

def additional_properties
  @additional_properties
end

#health_detailsSamsara::Types::HealthDetailsResponseResponseBody (readonly)



16
17
18
# File 'lib/samsara_api/types/health_response_response_body.rb', line 16

def health_details
  @health_details
end

#health_reasonsArray<Samsara::Types::HealthReasonResponseResponseBody> (readonly)

Returns The list of active health reasons affecting this device.

Returns:



18
19
20
# File 'lib/samsara_api/types/health_response_response_body.rb', line 18

def health_reasons
  @health_reasons
end

#health_statusObject (readonly)

‘healthy`, `needsAttention`, `needsReplacement`



21
22
23
# File 'lib/samsara_api/types/health_response_response_body.rb', line 21

def health_status
  @health_status
end

#primary_health_reasonObject (readonly)

‘outwardCameraObstruction`, `recordingTimeRequired`, `unknown`, `vgUnplugged`



28
29
30
# File 'lib/samsara_api/types/health_response_response_body.rb', line 28

def primary_health_reason
  @primary_health_reason
end

#primary_health_reason_start_timeDateTime (readonly)

Returns The timestamp when the primary health reason began, in RFC3339 format.

Returns:

  • (DateTime)

    The timestamp when the primary health reason began, in RFC3339 format.



30
31
32
# File 'lib/samsara_api/types/health_response_response_body.rb', line 30

def primary_health_reason_start_time
  @primary_health_reason_start_time
end

‘recommendedActionVgNotDetected`, `recommendedActionVgVgUnplugged`, `unknown`



115
116
117
# File 'lib/samsara_api/types/health_response_response_body.rb', line 115

def recommended_action
  @recommended_action
end

Class Method Details

.from_json(json_object:) ⇒ Samsara::Types::HealthResponseResponseBody

Parameters:

  • json_object (String)

Returns:



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
# File 'lib/samsara_api/types/health_response_response_body.rb', line 237

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  unless parsed_json["healthDetails"].nil?
    health_details = parsed_json["healthDetails"].to_json
    health_details = Samsara::Types::HealthDetailsResponseResponseBody.from_json(json_object: health_details)
  else
    health_details = nil
  end
  health_reasons = parsed_json["healthReasons"]&.map do | item |
  item = item.to_json
  Samsara::Types::HealthReasonResponseResponseBody.from_json(json_object: item)
end
  health_status = parsed_json["healthStatus"]
  primary_health_reason = parsed_json["primaryHealthReason"]
  primary_health_reason_start_time = unless parsed_json["primaryHealthReasonStartTime"].nil?
  DateTime.parse(parsed_json["primaryHealthReasonStartTime"])
else
  nil
end
  recommended_action = parsed_json["recommendedAction"]
  new(
    health_details: health_details,
    health_reasons: health_reasons,
    health_status: health_status,
    primary_health_reason: primary_health_reason,
    primary_health_reason_start_time: primary_health_reason_start_time,
    recommended_action: recommended_action,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


280
281
282
283
284
285
286
287
# File 'lib/samsara_api/types/health_response_response_body.rb', line 280

def self.validate_raw(obj:)
  obj.health_details.nil? || Samsara::Types::HealthDetailsResponseResponseBody.validate_raw(obj: obj.health_details)
  obj.health_reasons&.is_a?(Array) != false || raise("Passed value for field obj.health_reasons is not the expected type, validation failed.")
  obj.health_status&.is_a?(Samsara::Types::HealthResponseResponseBodyHealthStatus) != false || raise("Passed value for field obj.health_status is not the expected type, validation failed.")
  obj.primary_health_reason&.is_a?(Samsara::Types::HealthResponseResponseBodyPrimaryHealthReason) != false || raise("Passed value for field obj.primary_health_reason is not the expected type, validation failed.")
  obj.primary_health_reason_start_time&.is_a?(DateTime) != false || raise("Passed value for field obj.primary_health_reason_start_time is not the expected type, validation failed.")
  obj.recommended_action&.is_a?(Samsara::Types::HealthResponseResponseBodyRecommendedAction) != false || raise("Passed value for field obj.recommended_action is not the expected type, validation failed.")
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


271
272
273
# File 'lib/samsara_api/types/health_response_response_body.rb', line 271

def to_json
  @_field_set&.to_json
end