Class: Samsara::Types::HosLogEntry

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

Overview

A single HOS log entry.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(codrivers: OMIT, hos_status_type: OMIT, log_end_time: OMIT, log_recorded_location: OMIT, log_start_time:, remark: OMIT, vehicle: OMIT, additional_properties: nil) ⇒ Samsara::Types::HosLogEntry

Parameters:

  • log_end_time (String) (defaults to: OMIT)
  • log_recorded_location (Samsara::Types::HosLogLocation) (defaults to: OMIT)
  • log_start_time (String)
  • remark (String) (defaults to: OMIT)

    Remark associated with the log entry.

  • vehicle (Samsara::Types::VehicleTinyResponse) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/samsara_api/types/hos_log_entry.rb', line 46

def initialize(codrivers: OMIT, hos_status_type: OMIT, log_end_time: OMIT, log_recorded_location: OMIT, log_start_time:, remark: OMIT, vehicle: OMIT, additional_properties: nil)
  @codrivers = codrivers if codrivers != OMIT
  @hos_status_type = hos_status_type if hos_status_type != OMIT
  @log_end_time = log_end_time if log_end_time != OMIT
  @log_recorded_location = log_recorded_location if log_recorded_location != OMIT
  @log_start_time = log_start_time
  @remark = remark if remark != OMIT
  @vehicle = vehicle if vehicle != OMIT
  @additional_properties = additional_properties
  @_field_set = { "codrivers": codrivers, "hosStatusType": hos_status_type, "logEndTime": log_end_time, "logRecordedLocation": log_recorded_location, "logStartTime": log_start_time, "remark": remark, "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



29
30
31
# File 'lib/samsara_api/types/hos_log_entry.rb', line 29

def additional_properties
  @additional_properties
end

#codriversArray<Samsara::Types::DriverTinyResponse> (readonly)

Returns The codriver information.

Returns:



14
15
16
# File 'lib/samsara_api/types/hos_log_entry.rb', line 14

def codrivers
  @codrivers
end

#hos_status_typeObject (readonly)

‘driving`, `onDuty`, `yardMove`, `personalConveyance`.



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

def hos_status_type
  @hos_status_type
end

#log_end_timeString (readonly)

Returns:

  • (String)


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

def log_end_time
  @log_end_time
end

#log_recorded_locationSamsara::Types::HosLogLocation (readonly)



21
22
23
# File 'lib/samsara_api/types/hos_log_entry.rb', line 21

def log_recorded_location
  @log_recorded_location
end

#log_start_timeString (readonly)

Returns:

  • (String)


23
24
25
# File 'lib/samsara_api/types/hos_log_entry.rb', line 23

def log_start_time
  @log_start_time
end

#remarkString (readonly)

Returns Remark associated with the log entry.

Returns:

  • (String)

    Remark associated with the log entry.



25
26
27
# File 'lib/samsara_api/types/hos_log_entry.rb', line 25

def remark
  @remark
end

#vehicleSamsara::Types::VehicleTinyResponse (readonly)



27
28
29
# File 'lib/samsara_api/types/hos_log_entry.rb', line 27

def vehicle
  @vehicle
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



63
64
65
66
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
# File 'lib/samsara_api/types/hos_log_entry.rb', line 63

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  codrivers = parsed_json["codrivers"]&.map do | item |
  item = item.to_json
  Samsara::Types::DriverTinyResponse.from_json(json_object: item)
end
  hos_status_type = parsed_json["hosStatusType"]
  log_end_time = parsed_json["logEndTime"]
  unless parsed_json["logRecordedLocation"].nil?
    log_recorded_location = parsed_json["logRecordedLocation"].to_json
    log_recorded_location = Samsara::Types::HosLogLocation.from_json(json_object: log_recorded_location)
  else
    log_recorded_location = nil
  end
  log_start_time = parsed_json["logStartTime"]
  remark = parsed_json["remark"]
  unless parsed_json["vehicle"].nil?
    vehicle = parsed_json["vehicle"].to_json
    vehicle = Samsara::Types::VehicleTinyResponse.from_json(json_object: vehicle)
  else
    vehicle = nil
  end
  new(
    codrivers: codrivers,
    hos_status_type: hos_status_type,
    log_end_time: log_end_time,
    log_recorded_location: log_recorded_location,
    log_start_time: log_start_time,
    remark: remark,
    vehicle: vehicle,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


109
110
111
112
113
114
115
116
117
# File 'lib/samsara_api/types/hos_log_entry.rb', line 109

def self.validate_raw(obj:)
  obj.codrivers&.is_a?(Array) != false || raise("Passed value for field obj.codrivers is not the expected type, validation failed.")
  obj.hos_status_type&.is_a?(Samsara::Types::HosLogEntryHosStatusType) != false || raise("Passed value for field obj.hos_status_type is not the expected type, validation failed.")
  obj.log_end_time&.is_a?(String) != false || raise("Passed value for field obj.log_end_time is not the expected type, validation failed.")
  obj.log_recorded_location.nil? || Samsara::Types::HosLogLocation.validate_raw(obj: obj.log_recorded_location)
  obj.log_start_time.is_a?(String) != false || raise("Passed value for field obj.log_start_time is not the expected type, validation failed.")
  obj.remark&.is_a?(String) != false || raise("Passed value for field obj.remark is not the expected type, validation failed.")
  obj.vehicle.nil? || Samsara::Types::VehicleTinyResponse.validate_raw(obj: obj.vehicle)
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


100
101
102
# File 'lib/samsara_api/types/hos_log_entry.rb', line 100

def to_json
  @_field_set&.to_json
end