Class: Samsara::Types::AlertEventDvir
- Inherits:
-
Object
- Object
- Samsara::Types::AlertEventDvir
- Defined in:
- lib/samsara_api/types/alert_event_dvir.rb
Overview
DVIR-specific fields
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #defects ⇒ Array<Samsara::Types::AlertEventDvirDefectsItem> readonly
- #driver ⇒ Samsara::Types::AlertEventDvirDriver readonly
-
#dvir_id ⇒ String
readonly
ID of the DVIR.
- #inspection_type ⇒ Samsara::Types::AlertEventDvirInspectionType readonly
-
#odometer ⇒ Integer
readonly
Odometer value in meters.
- #safety_status ⇒ Samsara::Types::AlertEventDvirSafetyStatus readonly
- #trailer ⇒ Samsara::Types::AlertEventDvirTrailer readonly
- #vehicle ⇒ Samsara::Types::AlertEventDvirVehicle readonly
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(dvir_id: OMIT, vehicle: OMIT, trailer: OMIT, driver: OMIT, odometer: OMIT, inspection_type: OMIT, safety_status: OMIT, defects: OMIT, additional_properties: nil) ⇒ Samsara::Types::AlertEventDvir constructor
- #to_json ⇒ String
Constructor Details
#initialize(dvir_id: OMIT, vehicle: OMIT, trailer: OMIT, driver: OMIT, odometer: OMIT, inspection_type: OMIT, safety_status: OMIT, defects: OMIT, additional_properties: nil) ⇒ Samsara::Types::AlertEventDvir
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/samsara_api/types/alert_event_dvir.rb', line 49 def initialize(dvir_id: OMIT, vehicle: OMIT, trailer: OMIT, driver: OMIT, odometer: OMIT, inspection_type: OMIT, safety_status: OMIT, defects: OMIT, additional_properties: nil) @dvir_id = dvir_id if dvir_id != OMIT @vehicle = vehicle if vehicle != OMIT @trailer = trailer if trailer != OMIT @driver = driver if driver != OMIT @odometer = odometer if odometer != OMIT @inspection_type = inspection_type if inspection_type != OMIT @safety_status = safety_status if safety_status != OMIT @defects = defects if defects != OMIT @additional_properties = additional_properties @_field_set = { "dvirId": dvir_id, "vehicle": vehicle, "trailer": trailer, "driver": driver, "odometer": odometer, "inspectionType": inspection_type, "safetyStatus": safety_status, "defects": defects }.reject do | _k, v | v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
32 33 34 |
# File 'lib/samsara_api/types/alert_event_dvir.rb', line 32 def additional_properties @additional_properties end |
#defects ⇒ Array<Samsara::Types::AlertEventDvirDefectsItem> (readonly)
30 31 32 |
# File 'lib/samsara_api/types/alert_event_dvir.rb', line 30 def defects @defects end |
#driver ⇒ Samsara::Types::AlertEventDvirDriver (readonly)
22 23 24 |
# File 'lib/samsara_api/types/alert_event_dvir.rb', line 22 def driver @driver end |
#dvir_id ⇒ String (readonly)
Returns ID of the DVIR.
16 17 18 |
# File 'lib/samsara_api/types/alert_event_dvir.rb', line 16 def dvir_id @dvir_id end |
#inspection_type ⇒ Samsara::Types::AlertEventDvirInspectionType (readonly)
26 27 28 |
# File 'lib/samsara_api/types/alert_event_dvir.rb', line 26 def inspection_type @inspection_type end |
#odometer ⇒ Integer (readonly)
Returns Odometer value in meters.
24 25 26 |
# File 'lib/samsara_api/types/alert_event_dvir.rb', line 24 def odometer @odometer end |
#safety_status ⇒ Samsara::Types::AlertEventDvirSafetyStatus (readonly)
28 29 30 |
# File 'lib/samsara_api/types/alert_event_dvir.rb', line 28 def safety_status @safety_status end |
#trailer ⇒ Samsara::Types::AlertEventDvirTrailer (readonly)
20 21 22 |
# File 'lib/samsara_api/types/alert_event_dvir.rb', line 20 def trailer @trailer end |
#vehicle ⇒ Samsara::Types::AlertEventDvirVehicle (readonly)
18 19 20 |
# File 'lib/samsara_api/types/alert_event_dvir.rb', line 18 def vehicle @vehicle end |
Class Method Details
.from_json(json_object:) ⇒ Samsara::Types::AlertEventDvir
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/samsara_api/types/alert_event_dvir.rb', line 67 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) dvir_id = parsed_json["dvirId"] unless parsed_json["vehicle"].nil? vehicle = parsed_json["vehicle"].to_json vehicle = Samsara::Types::AlertEventDvirVehicle.from_json(json_object: vehicle) else vehicle = nil end unless parsed_json["trailer"].nil? trailer = parsed_json["trailer"].to_json trailer = Samsara::Types::AlertEventDvirTrailer.from_json(json_object: trailer) else trailer = nil end unless parsed_json["driver"].nil? driver = parsed_json["driver"].to_json driver = Samsara::Types::AlertEventDvirDriver.from_json(json_object: driver) else driver = nil end odometer = parsed_json["odometer"] inspection_type = parsed_json["inspectionType"] safety_status = parsed_json["safetyStatus"] defects = parsed_json["defects"]&.map do | item | item = item.to_json Samsara::Types::AlertEventDvirDefectsItem.from_json(json_object: item) end new( dvir_id: dvir_id, vehicle: vehicle, trailer: trailer, driver: driver, odometer: odometer, inspection_type: inspection_type, safety_status: safety_status, defects: defects, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
120 121 122 123 124 125 126 127 128 129 |
# File 'lib/samsara_api/types/alert_event_dvir.rb', line 120 def self.validate_raw(obj:) obj.dvir_id&.is_a?(String) != false || raise("Passed value for field obj.dvir_id is not the expected type, validation failed.") obj.vehicle.nil? || Samsara::Types::AlertEventDvirVehicle.validate_raw(obj: obj.vehicle) obj.trailer.nil? || Samsara::Types::AlertEventDvirTrailer.validate_raw(obj: obj.trailer) obj.driver.nil? || Samsara::Types::AlertEventDvirDriver.validate_raw(obj: obj.driver) obj.odometer&.is_a?(Integer) != false || raise("Passed value for field obj.odometer is not the expected type, validation failed.") obj.inspection_type&.is_a?(Samsara::Types::AlertEventDvirInspectionType) != false || raise("Passed value for field obj.inspection_type is not the expected type, validation failed.") obj.safety_status&.is_a?(Samsara::Types::AlertEventDvirSafetyStatus) != false || raise("Passed value for field obj.safety_status is not the expected type, validation failed.") obj.defects&.is_a?(Array) != false || raise("Passed value for field obj.defects is not the expected type, validation failed.") end |
Instance Method Details
#to_json ⇒ String
111 112 113 |
# File 'lib/samsara_api/types/alert_event_dvir.rb', line 111 def to_json @_field_set&.to_json end |