Class: Samsara::Types::Defect
- Inherits:
-
Object
- Object
- Samsara::Types::Defect
- Defined in:
- lib/samsara_api/types/defect.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#comment ⇒ String
readonly
Comment on the defect.
-
#created_at_time ⇒ Object
readonly
‘2020-01-27T07:06:25Z`.
-
#defect_type ⇒ String
readonly
The type of DVIR defect.
-
#id ⇒ String
readonly
ID of the defect.
-
#is_resolved ⇒ Boolean
readonly
Signifies if this defect is resolved.
-
#mechanic_notes ⇒ String
readonly
The mechanics notes on the defect.
-
#mechanic_notes_updated_at_time ⇒ Object
readonly
Example: ‘2020-01-27T07:06:25Z`.
-
#resolved_at_time ⇒ Object
readonly
unresolved.
- #resolved_by ⇒ Samsara::Types::DefectResolvedBy readonly
- #trailer ⇒ Samsara::Types::DefectTrailer readonly
- #vehicle ⇒ Samsara::Types::DefectVehicle readonly
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(comment: OMIT, created_at_time: OMIT, defect_type: OMIT, id:, is_resolved:, mechanic_notes: OMIT, mechanic_notes_updated_at_time: OMIT, resolved_at_time: OMIT, resolved_by: OMIT, trailer: OMIT, vehicle: OMIT, additional_properties: nil) ⇒ Samsara::Types::Defect constructor
- #to_json ⇒ String
Constructor Details
#initialize(comment: OMIT, created_at_time: OMIT, defect_type: OMIT, id:, is_resolved:, mechanic_notes: OMIT, mechanic_notes_updated_at_time: OMIT, resolved_at_time: OMIT, resolved_by: OMIT, trailer: OMIT, vehicle: OMIT, additional_properties: nil) ⇒ Samsara::Types::Defect
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/samsara_api/types/defect.rb', line 60 def initialize(comment: OMIT, created_at_time: OMIT, defect_type: OMIT, id:, is_resolved:, mechanic_notes: OMIT, mechanic_notes_updated_at_time: OMIT, resolved_at_time: OMIT, resolved_by: OMIT, trailer: OMIT, vehicle: OMIT, additional_properties: nil) @comment = comment if comment != OMIT @created_at_time = created_at_time if created_at_time != OMIT @defect_type = defect_type if defect_type != OMIT @id = id @is_resolved = is_resolved @mechanic_notes = mechanic_notes if mechanic_notes != OMIT @mechanic_notes_updated_at_time = mechanic_notes_updated_at_time if mechanic_notes_updated_at_time != OMIT @resolved_at_time = resolved_at_time if resolved_at_time != OMIT @resolved_by = resolved_by if resolved_by != OMIT @trailer = trailer if trailer != OMIT @vehicle = vehicle if vehicle != OMIT @additional_properties = additional_properties @_field_set = { "comment": comment, "createdAtTime": created_at_time, "defectType": defect_type, "id": id, "isResolved": is_resolved, "mechanicNotes": mechanic_notes, "mechanicNotesUpdatedAtTime": mechanic_notes_updated_at_time, "resolvedAtTime": resolved_at_time, "resolvedBy": resolved_by, "trailer": trailer, "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.
37 38 39 |
# File 'lib/samsara_api/types/defect.rb', line 37 def additional_properties @additional_properties end |
#comment ⇒ String (readonly)
Returns Comment on the defect.
12 13 14 |
# File 'lib/samsara_api/types/defect.rb', line 12 def comment @comment end |
#created_at_time ⇒ Object (readonly)
‘2020-01-27T07:06:25Z`.
15 16 17 |
# File 'lib/samsara_api/types/defect.rb', line 15 def created_at_time @created_at_time end |
#defect_type ⇒ String (readonly)
Returns The type of DVIR defect.
17 18 19 |
# File 'lib/samsara_api/types/defect.rb', line 17 def defect_type @defect_type end |
#id ⇒ String (readonly)
Returns ID of the defect.
19 20 21 |
# File 'lib/samsara_api/types/defect.rb', line 19 def id @id end |
#is_resolved ⇒ Boolean (readonly)
Returns Signifies if this defect is resolved.
21 22 23 |
# File 'lib/samsara_api/types/defect.rb', line 21 def is_resolved @is_resolved end |
#mechanic_notes ⇒ String (readonly)
Returns The mechanics notes on the defect.
23 24 25 |
# File 'lib/samsara_api/types/defect.rb', line 23 def mechanic_notes @mechanic_notes end |
#mechanic_notes_updated_at_time ⇒ Object (readonly)
Example: ‘2020-01-27T07:06:25Z`.
26 27 28 |
# File 'lib/samsara_api/types/defect.rb', line 26 def mechanic_notes_updated_at_time @mechanic_notes_updated_at_time end |
#resolved_at_time ⇒ Object (readonly)
unresolved. UTC timestamp in RFC 3339 format. Example: ‘2020-01-27T07:06:25Z`.
29 30 31 |
# File 'lib/samsara_api/types/defect.rb', line 29 def resolved_at_time @resolved_at_time end |
#resolved_by ⇒ Samsara::Types::DefectResolvedBy (readonly)
31 32 33 |
# File 'lib/samsara_api/types/defect.rb', line 31 def resolved_by @resolved_by end |
#trailer ⇒ Samsara::Types::DefectTrailer (readonly)
33 34 35 |
# File 'lib/samsara_api/types/defect.rb', line 33 def trailer @trailer end |
#vehicle ⇒ Samsara::Types::DefectVehicle (readonly)
35 36 37 |
# File 'lib/samsara_api/types/defect.rb', line 35 def vehicle @vehicle end |
Class Method Details
.from_json(json_object:) ⇒ Samsara::Types::Defect
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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/samsara_api/types/defect.rb', line 81 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) comment = parsed_json["comment"] created_at_time = parsed_json["createdAtTime"] defect_type = parsed_json["defectType"] id = parsed_json["id"] is_resolved = parsed_json["isResolved"] mechanic_notes = parsed_json["mechanicNotes"] mechanic_notes_updated_at_time = parsed_json["mechanicNotesUpdatedAtTime"] resolved_at_time = parsed_json["resolvedAtTime"] unless parsed_json["resolvedBy"].nil? resolved_by = parsed_json["resolvedBy"].to_json resolved_by = Samsara::Types::DefectResolvedBy.from_json(json_object: resolved_by) else resolved_by = nil end unless parsed_json["trailer"].nil? trailer = parsed_json["trailer"].to_json trailer = Samsara::Types::DefectTrailer.from_json(json_object: trailer) else trailer = nil end unless parsed_json["vehicle"].nil? vehicle = parsed_json["vehicle"].to_json vehicle = Samsara::Types::DefectVehicle.from_json(json_object: vehicle) else vehicle = nil end new( comment: comment, created_at_time: created_at_time, defect_type: defect_type, id: id, is_resolved: is_resolved, mechanic_notes: mechanic_notes, mechanic_notes_updated_at_time: mechanic_notes_updated_at_time, resolved_at_time: resolved_at_time, resolved_by: resolved_by, trailer: trailer, vehicle: vehicle, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/samsara_api/types/defect.rb', line 137 def self.validate_raw(obj:) obj.comment&.is_a?(String) != false || raise("Passed value for field obj.comment is not the expected type, validation failed.") obj.created_at_time&.is_a?(String) != false || raise("Passed value for field obj.created_at_time is not the expected type, validation failed.") obj.defect_type&.is_a?(String) != false || raise("Passed value for field obj.defect_type is not the expected type, validation failed.") obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.is_resolved.is_a?(Boolean) != false || raise("Passed value for field obj.is_resolved is not the expected type, validation failed.") obj.mechanic_notes&.is_a?(String) != false || raise("Passed value for field obj.mechanic_notes is not the expected type, validation failed.") obj.mechanic_notes_updated_at_time&.is_a?(String) != false || raise("Passed value for field obj.mechanic_notes_updated_at_time is not the expected type, validation failed.") obj.resolved_at_time&.is_a?(String) != false || raise("Passed value for field obj.resolved_at_time is not the expected type, validation failed.") obj.resolved_by.nil? || Samsara::Types::DefectResolvedBy.validate_raw(obj: obj.resolved_by) obj.trailer.nil? || Samsara::Types::DefectTrailer.validate_raw(obj: obj.trailer) obj.vehicle.nil? || Samsara::Types::DefectVehicle.validate_raw(obj: obj.vehicle) end |
Instance Method Details
#to_json ⇒ String
128 129 130 |
# File 'lib/samsara_api/types/defect.rb', line 128 def to_json @_field_set&.to_json end |