Class: Samsara::Types::WorkflowDvirObjectResponseBody

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

Overview

A DVIR description

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(author_signature:, defects: OMIT, end_time:, formatted_location: OMIT, id:, mechanic_notes: OMIT, needs_correction:, odometer_meters: OMIT, safety_status:, second_signature: OMIT, start_time:, third_signature: OMIT, trailer: OMIT, type:, additional_properties: nil) ⇒ Samsara::Types::WorkflowDvirObjectResponseBody

Parameters:

  • additional_properties (OpenStruct) (defaults to: nil) —

    Additional properties unmapped to the current class definition



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/samsara_api/types/workflow_dvir_object_response_body.rb', line 72

def initialize(author_signature:, defects: OMIT, end_time:, formatted_location: OMIT, id:, mechanic_notes: OMIT, needs_correction:, odometer_meters: OMIT, safety_status:, second_signature: OMIT, start_time:, third_signature: OMIT, trailer: OMIT, type:, additional_properties: nil)
  @author_signature = author_signature
  @defects = defects if defects != OMIT
  @end_time = end_time
  @formatted_location = formatted_location if formatted_location != OMIT
  @id = id
  @mechanic_notes = mechanic_notes if mechanic_notes != OMIT
  @needs_correction = needs_correction
  @odometer_meters = odometer_meters if odometer_meters != OMIT
  @safety_status = safety_status
  @second_signature = second_signature if second_signature != OMIT
  @start_time = start_time
  @third_signature = third_signature if third_signature != OMIT
  @trailer = trailer if trailer != OMIT
  @type = type
  @additional_properties = additional_properties
  @_field_set = { "authorSignature": author_signature, "defects": defects, "endTime": end_time, "formattedLocation": formatted_location, "id": id, "mechanicNotes": mechanic_notes, "needsCorrection": needs_correction, "odometerMeters": odometer_meters, "safetyStatus": safety_status, "secondSignature": second_signature, "startTime": start_time, "thirdSignature": third_signature, "trailer": trailer, "type": type }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_properties ⇒ OpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct) —

    Additional properties unmapped to the current class definition



46
47
48
# File 'lib/samsara_api/types/workflow_dvir_object_response_body.rb', line 46

def additional_properties
  @additional_properties
end

#author_signature ⇒ Samsara::Types::WorkflowAuthorSignatureObjectResponseBody (readonly)



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

def author_signature
  @author_signature
end

#defects ⇒ Array<Samsara::Types::DvirDefectsObjectV20220913ResponseBody> (readonly)

Returns Defects registered for the DVIR.

Returns:



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

def defects
  @defects
end

#end_time ⇒ Object (readonly)

format.



20
21
22
# File 'lib/samsara_api/types/workflow_dvir_object_response_body.rb', line 20

def end_time
  @end_time
end

#formatted_location ⇒ String (readonly)

Returns Optional string if your jurisdiction requires a location of the DVIR.

Returns:

  • (String) —

    Optional string if your jurisdiction requires a location of the DVIR.



22
23
24
# File 'lib/samsara_api/types/workflow_dvir_object_response_body.rb', line 22

def formatted_location
  @formatted_location
end

#id ⇒ String (readonly)

Returns The unique id of the DVIR.

Returns:

  • (String) —

    The unique id of the DVIR



24
25
26
# File 'lib/samsara_api/types/workflow_dvir_object_response_body.rb', line 24

def id
  @id
end

#mechanic_notes ⇒ String (readonly)

Returns The mechanics notes on the DVIR.

Returns:

  • (String) —

    The mechanics notes on the DVIR.



26
27
28
# File 'lib/samsara_api/types/workflow_dvir_object_response_body.rb', line 26

def mechanic_notes
  @mechanic_notes
end

#needs_correction ⇒ Boolean (readonly)

Returns Indicates if a defect needs correction.

Returns:

  • (Boolean) —

    Indicates if a defect needs correction.



28
29
30
# File 'lib/samsara_api/types/workflow_dvir_object_response_body.rb', line 28

def needs_correction
  @needs_correction
end

#odometer_meters ⇒ Long (readonly)

Returns The odometer reading in meters.

Returns:

  • (Long) —

    The odometer reading in meters.



30
31
32
# File 'lib/samsara_api/types/workflow_dvir_object_response_body.rb', line 30

def odometer_meters
  @odometer_meters
end

#safety_status ⇒ Object (readonly)

unsafe, resolved



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

def safety_status
  @safety_status
end

#second_signature ⇒ Samsara::Types::WorkflowAuthorSignatureObjectResponseBody (readonly)



35
36
37
# File 'lib/samsara_api/types/workflow_dvir_object_response_body.rb', line 35

def second_signature
  @second_signature
end

#start_time ⇒ String (readonly)

Returns Time when driver began filling out this DVIR in RFC 3339 format.

Returns:

  • (String) —

    Time when driver began filling out this DVIR in RFC 3339 format.



37
38
39
# File 'lib/samsara_api/types/workflow_dvir_object_response_body.rb', line 37

def start_time
  @start_time
end

#third_signature ⇒ Samsara::Types::WorkflowAuthorSignatureObjectResponseBody (readonly)



39
40
41
# File 'lib/samsara_api/types/workflow_dvir_object_response_body.rb', line 39

def third_signature
  @third_signature
end

#trailer ⇒ Samsara::Types::GoaTrailerTinyResponseResponseBody (readonly)



41
42
43
# File 'lib/samsara_api/types/workflow_dvir_object_response_body.rb', line 41

def trailer
  @trailer
end

#type ⇒ Object (readonly)

unspecified



44
45
46
# File 'lib/samsara_api/types/workflow_dvir_object_response_body.rb', line 44

def type
  @type
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/samsara_api/types/workflow_dvir_object_response_body.rb', line 96

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  unless parsed_json["authorSignature"].nil?
    author_signature = parsed_json["authorSignature"].to_json
    author_signature = Samsara::Types::WorkflowAuthorSignatureObjectResponseBody.from_json(json_object: author_signature)
  else
    author_signature = nil
  end
  defects = parsed_json["defects"]&.map do | item |
  item = item.to_json
  Samsara::Types::DvirDefectsObjectV20220913ResponseBody.from_json(json_object: item)
end
  end_time = parsed_json["endTime"]
  formatted_location = parsed_json["formattedLocation"]
  id = parsed_json["id"]
  mechanic_notes = parsed_json["mechanicNotes"]
  needs_correction = parsed_json["needsCorrection"]
  odometer_meters = parsed_json["odometerMeters"]
  safety_status = parsed_json["safetyStatus"]
  unless parsed_json["secondSignature"].nil?
    second_signature = parsed_json["secondSignature"].to_json
    second_signature = Samsara::Types::WorkflowAuthorSignatureObjectResponseBody.from_json(json_object: second_signature)
  else
    second_signature = nil
  end
  start_time = parsed_json["startTime"]
  unless parsed_json["thirdSignature"].nil?
    third_signature = parsed_json["thirdSignature"].to_json
    third_signature = Samsara::Types::WorkflowAuthorSignatureObjectResponseBody.from_json(json_object: third_signature)
  else
    third_signature = nil
  end
  unless parsed_json["trailer"].nil?
    trailer = parsed_json["trailer"].to_json
    trailer = Samsara::Types::GoaTrailerTinyResponseResponseBody.from_json(json_object: trailer)
  else
    trailer = nil
  end
  type = parsed_json["type"]
  new(
    author_signature: author_signature,
    defects: defects,
    end_time: end_time,
    formatted_location: formatted_location,
    id: id,
    mechanic_notes: mechanic_notes,
    needs_correction: needs_correction,
    odometer_meters: odometer_meters,
    safety_status: safety_status,
    second_signature: second_signature,
    start_time: start_time,
    third_signature: third_signature,
    trailer: trailer,
    type: type,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/samsara_api/types/workflow_dvir_object_response_body.rb', line 166

def self.validate_raw(obj:)
  Samsara::Types::WorkflowAuthorSignatureObjectResponseBody.validate_raw(obj: obj.author_signature)
  obj.defects&.is_a?(Array) != false || raise("Passed value for field obj.defects is not the expected type, validation failed.")
  obj.end_time.is_a?(String) != false || raise("Passed value for field obj.end_time is not the expected type, validation failed.")
  obj.formatted_location&.is_a?(String) != false || raise("Passed value for field obj.formatted_location 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.mechanic_notes&.is_a?(String) != false || raise("Passed value for field obj.mechanic_notes is not the expected type, validation failed.")
  obj.needs_correction.is_a?(Boolean) != false || raise("Passed value for field obj.needs_correction is not the expected type, validation failed.")
  obj.odometer_meters&.is_a?(Long) != false || raise("Passed value for field obj.odometer_meters is not the expected type, validation failed.")
  obj.safety_status.is_a?(Samsara::Types::WorkflowDvirObjectResponseBodySafetyStatus) != false || raise("Passed value for field obj.safety_status is not the expected type, validation failed.")
  obj.second_signature.nil? || Samsara::Types::WorkflowAuthorSignatureObjectResponseBody.validate_raw(obj: obj.second_signature)
  obj.start_time.is_a?(String) != false || raise("Passed value for field obj.start_time is not the expected type, validation failed.")
  obj.third_signature.nil? || Samsara::Types::WorkflowAuthorSignatureObjectResponseBody.validate_raw(obj: obj.third_signature)
  obj.trailer.nil? || Samsara::Types::GoaTrailerTinyResponseResponseBody.validate_raw(obj: obj.trailer)
  obj.type.is_a?(Samsara::Types::WorkflowDvirObjectResponseBodyType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
end

Instance Method Details

#to_json ⇒ String

Returns:

  • (String)


157
158
159
# File 'lib/samsara_api/types/workflow_dvir_object_response_body.rb', line 157

def to_json
  @_field_set&.to_json
end