Class: Samsara::Types::SafetyEventObjectResponseBody

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

Overview

The safety event that was updated.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(behavior_labels: OMIT, driver: OMIT, id: OMIT, time: OMIT, vehicle: OMIT, additional_properties: nil) ⇒ Samsara::Types::SafetyEventObjectResponseBody

Parameters:



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/samsara_api/types/safety_event_object_response_body.rb', line 37

def initialize(behavior_labels: OMIT, driver: OMIT, id: OMIT, time: OMIT, vehicle: OMIT, additional_properties: nil)
  @behavior_labels = behavior_labels if behavior_labels != OMIT
  @driver = driver if driver != OMIT
  @id = id if id != OMIT
  @time = time if time != OMIT
  @vehicle = vehicle if vehicle != OMIT
  @additional_properties = additional_properties
  @_field_set = { "behaviorLabels": behavior_labels, "driver": driver, "id": id, "time": time, "vehicle": vehicle }.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



23
24
25
# File 'lib/samsara_api/types/safety_event_object_response_body.rb', line 23

def additional_properties
  @additional_properties
end

#behavior_labelsArray<Samsara::Types::SafetyEventBehaviorLabelsResponseBody> (readonly)

Returns Behavior labels for a safety event.

Returns:



13
14
15
# File 'lib/samsara_api/types/safety_event_object_response_body.rb', line 13

def behavior_labels
  @behavior_labels
end

#driverSamsara::Types::SafetyEventDriverObjectResponseBody (readonly)



15
16
17
# File 'lib/samsara_api/types/safety_event_object_response_body.rb', line 15

def driver
  @driver
end

#idString (readonly)

Returns The unique Samsara ID of the safety event.

Returns:

  • (String)

    The unique Samsara ID of the safety event.



17
18
19
# File 'lib/samsara_api/types/safety_event_object_response_body.rb', line 17

def id
  @id
end

#timeString (readonly)

Returns The time the safety event occurred in RFC 3339 milliseconds format.

Returns:

  • (String)

    The time the safety event occurred in RFC 3339 milliseconds format.



19
20
21
# File 'lib/samsara_api/types/safety_event_object_response_body.rb', line 19

def time
  @time
end

#vehicleSamsara::Types::SafetyEventVehicleObjectResponseBody (readonly)



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

def vehicle
  @vehicle
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/samsara_api/types/safety_event_object_response_body.rb', line 52

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  behavior_labels = parsed_json["behaviorLabels"]&.map do | item |
  item = item.to_json
  Samsara::Types::SafetyEventBehaviorLabelsResponseBody.from_json(json_object: item)
end
  unless parsed_json["driver"].nil?
    driver = parsed_json["driver"].to_json
    driver = Samsara::Types::SafetyEventDriverObjectResponseBody.from_json(json_object: driver)
  else
    driver = nil
  end
  id = parsed_json["id"]
  time = parsed_json["time"]
  unless parsed_json["vehicle"].nil?
    vehicle = parsed_json["vehicle"].to_json
    vehicle = Samsara::Types::SafetyEventVehicleObjectResponseBody.from_json(json_object: vehicle)
  else
    vehicle = nil
  end
  new(
    behavior_labels: behavior_labels,
    driver: driver,
    id: id,
    time: time,
    vehicle: vehicle,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


94
95
96
97
98
99
100
# File 'lib/samsara_api/types/safety_event_object_response_body.rb', line 94

def self.validate_raw(obj:)
  obj.behavior_labels&.is_a?(Array) != false || raise("Passed value for field obj.behavior_labels is not the expected type, validation failed.")
  obj.driver.nil? || Samsara::Types::SafetyEventDriverObjectResponseBody.validate_raw(obj: obj.driver)
  obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.time&.is_a?(String) != false || raise("Passed value for field obj.time is not the expected type, validation failed.")
  obj.vehicle.nil? || Samsara::Types::SafetyEventVehicleObjectResponseBody.validate_raw(obj: obj.vehicle)
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


85
86
87
# File 'lib/samsara_api/types/safety_event_object_response_body.rb', line 85

def to_json
  @_field_set&.to_json
end