Class: Samsara::Types::Defect

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

Parameters:



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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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

#commentString (readonly)

Returns Comment on the defect.

Returns:

  • (String)

    Comment on the defect.



12
13
14
# File 'lib/samsara_api/types/defect.rb', line 12

def comment
  @comment
end

#created_at_timeObject (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_typeString (readonly)

Returns The type of DVIR defect.

Returns:

  • (String)

    The type of DVIR defect.



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

def defect_type
  @defect_type
end

#idString (readonly)

Returns ID of the defect.

Returns:

  • (String)

    ID of the defect.



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

def id
  @id
end

#is_resolvedBoolean (readonly)

Returns Signifies if this defect is resolved.

Returns:

  • (Boolean)

    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_notesString (readonly)

Returns The mechanics notes on the defect.

Returns:

  • (String)

    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_timeObject (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_timeObject (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_bySamsara::Types::DefectResolvedBy (readonly)



31
32
33
# File 'lib/samsara_api/types/defect.rb', line 31

def resolved_by
  @resolved_by
end

#trailerSamsara::Types::DefectTrailer (readonly)



33
34
35
# File 'lib/samsara_api/types/defect.rb', line 33

def trailer
  @trailer
end

#vehicleSamsara::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

Parameters:

  • json_object (String)

Returns:



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

Parameters:

  • obj (Object)

Returns:

  • (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_jsonString

Returns:

  • (String)


128
129
130
# File 'lib/samsara_api/types/defect.rb', line 128

def to_json
  @_field_set&.to_json
end