Class: Samsara::Types::SafetyEvent

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

Overview

A safety event.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(behavior_labels: OMIT, coaching_state: OMIT, download_forward_video_url: OMIT, download_inward_video_url: OMIT, download_tracked_inward_video_url: OMIT, driver: OMIT, id: OMIT, location: OMIT, max_acceleration_g_force: OMIT, time: OMIT, vehicle: OMIT, additional_properties: nil) ⇒ Samsara::Types::SafetyEvent

Parameters:



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/samsara_api/types/safety_event.rb', line 57

def initialize(behavior_labels: OMIT, coaching_state: OMIT, download_forward_video_url: OMIT, download_inward_video_url: OMIT, download_tracked_inward_video_url: OMIT, driver: OMIT, id: OMIT, location: OMIT, max_acceleration_g_force: OMIT, time: OMIT, vehicle: OMIT, additional_properties: nil)
  @behavior_labels = behavior_labels if behavior_labels != OMIT
  @coaching_state = coaching_state if coaching_state != OMIT
  @download_forward_video_url = download_forward_video_url if download_forward_video_url != OMIT
  @download_inward_video_url = download_inward_video_url if download_inward_video_url != OMIT
  @download_tracked_inward_video_url = download_tracked_inward_video_url if download_tracked_inward_video_url != OMIT
  @driver = driver if driver != OMIT
  @id = id if id != OMIT
  @location = location if location != OMIT
  @max_acceleration_g_force = max_acceleration_g_force if max_acceleration_g_force != OMIT
  @time = time if time != OMIT
  @vehicle = vehicle if vehicle != OMIT
  @additional_properties = additional_properties
  @_field_set = { "behaviorLabels": behavior_labels, "coachingState": coaching_state, "downloadForwardVideoUrl": download_forward_video_url, "downloadInwardVideoUrl": download_inward_video_url, "downloadTrackedInwardVideoUrl": download_tracked_inward_video_url, "driver": driver, "id": id, "location": location, "maxAccelerationGForce": max_acceleration_g_force, "time": time, "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/safety_event.rb', line 37

def additional_properties
  @additional_properties
end

#behavior_labelsSamsara::Types::SAFETY_EVENT_BEHAVIOR_LABELS (readonly)



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

def behavior_labels
  @behavior_labels
end

#coaching_stateSamsara::Types::SafetyEventCoachingState (readonly)



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

def coaching_state
  @coaching_state
end

#download_forward_video_urlString (readonly)

Returns:

  • (String)


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

def download_forward_video_url
  @download_forward_video_url
end

#download_inward_video_urlString (readonly)

Returns:

  • (String)


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

def download_inward_video_url
  @download_inward_video_url
end

#download_tracked_inward_video_urlString (readonly)

Returns:

  • (String)


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

def download_tracked_inward_video_url
  @download_tracked_inward_video_url
end

#driverSamsara::Types::DriverTinyResponse (readonly)



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

def driver
  @driver
end

#idString (readonly)

Returns:

  • (String)


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

def id
  @id
end

#locationSamsara::Types::Location (readonly)



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

def location
  @location
end

#max_acceleration_g_forceFloat (readonly)

Returns:

  • (Float)


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

def max_acceleration_g_force
  @max_acceleration_g_force
end

#timeString (readonly)

Returns:

  • (String)


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

def time
  @time
end

#vehicleSamsara::Types::VehicleTinyResponse (readonly)



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

def vehicle
  @vehicle
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/samsara_api/types/safety_event.rb', line 78

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  behavior_labels = parsed_json["behaviorLabels"]&.map do | item |
  item = item.to_json
  Samsara::Types::SafetyEventBehaviorLabel.from_json(json_object: item)
end
  coaching_state = parsed_json["coachingState"]
  download_forward_video_url = parsed_json["downloadForwardVideoUrl"]
  download_inward_video_url = parsed_json["downloadInwardVideoUrl"]
  download_tracked_inward_video_url = parsed_json["downloadTrackedInwardVideoUrl"]
  unless parsed_json["driver"].nil?
    driver = parsed_json["driver"].to_json
    driver = Samsara::Types::DriverTinyResponse.from_json(json_object: driver)
  else
    driver = nil
  end
  id = parsed_json["id"]
  unless parsed_json["location"].nil?
    location = parsed_json["location"].to_json
    location = Samsara::Types::Location.from_json(json_object: location)
  else
    location = nil
  end
  max_acceleration_g_force = parsed_json["maxAccelerationGForce"]
  time = parsed_json["time"]
  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(
    behavior_labels: behavior_labels,
    coaching_state: coaching_state,
    download_forward_video_url: download_forward_video_url,
    download_inward_video_url: download_inward_video_url,
    download_tracked_inward_video_url: download_tracked_inward_video_url,
    driver: driver,
    id: id,
    location: location,
    max_acceleration_g_force: max_acceleration_g_force,
    time: time,
    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/safety_event.rb', line 137

def self.validate_raw(obj:)
  obj.behavior_labels&.is_a?(Array) != false || raise("Passed value for field obj.behavior_labels is not the expected type, validation failed.")
  obj.coaching_state&.is_a?(Samsara::Types::SafetyEventCoachingState) != false || raise("Passed value for field obj.coaching_state is not the expected type, validation failed.")
  obj.download_forward_video_url&.is_a?(String) != false || raise("Passed value for field obj.download_forward_video_url is not the expected type, validation failed.")
  obj.download_inward_video_url&.is_a?(String) != false || raise("Passed value for field obj.download_inward_video_url is not the expected type, validation failed.")
  obj.download_tracked_inward_video_url&.is_a?(String) != false || raise("Passed value for field obj.download_tracked_inward_video_url is not the expected type, validation failed.")
  obj.driver.nil? || Samsara::Types::DriverTinyResponse.validate_raw(obj: obj.driver)
  obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.location.nil? || Samsara::Types::Location.validate_raw(obj: obj.location)
  obj.max_acceleration_g_force&.is_a?(Float) != false || raise("Passed value for field obj.max_acceleration_g_force is not the expected type, validation failed.")
  obj.time&.is_a?(String) != false || raise("Passed value for field obj.time 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)


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

def to_json
  @_field_set&.to_json
end