Class: Samsara::Types::SafetyEventObjectResponseBody
- Inherits:
-
Object
- Object
- Samsara::Types::SafetyEventObjectResponseBody
- 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
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#behavior_labels ⇒ Array<Samsara::Types::SafetyEventBehaviorLabelsResponseBody>
readonly
Behavior labels for a safety event.
- #driver ⇒ Samsara::Types::SafetyEventDriverObjectResponseBody readonly
-
#id ⇒ String
readonly
The unique Samsara ID of the safety event.
-
#time ⇒ String
readonly
The time the safety event occurred in RFC 3339 milliseconds format.
- #vehicle ⇒ Samsara::Types::SafetyEventVehicleObjectResponseBody readonly
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(behavior_labels: OMIT, driver: OMIT, id: OMIT, time: OMIT, vehicle: OMIT, additional_properties: nil) ⇒ Samsara::Types::SafetyEventObjectResponseBody constructor
- #to_json ⇒ String
Constructor Details
#initialize(behavior_labels: OMIT, driver: OMIT, id: OMIT, time: OMIT, vehicle: OMIT, additional_properties: nil) ⇒ Samsara::Types::SafetyEventObjectResponseBody
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_properties ⇒ OpenStruct (readonly)
Returns 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_labels ⇒ Array<Samsara::Types::SafetyEventBehaviorLabelsResponseBody> (readonly)
Returns Behavior labels for a safety event.
13 14 15 |
# File 'lib/samsara_api/types/safety_event_object_response_body.rb', line 13 def behavior_labels @behavior_labels end |
#driver ⇒ Samsara::Types::SafetyEventDriverObjectResponseBody (readonly)
15 16 17 |
# File 'lib/samsara_api/types/safety_event_object_response_body.rb', line 15 def driver @driver end |
#id ⇒ String (readonly)
Returns 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 |
#time ⇒ String (readonly)
Returns 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 |
#vehicle ⇒ Samsara::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
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
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_json ⇒ 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 |