Class: Samsara::Types::SafetyEventActivityFeedItemResponseBody

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

Overview

Safety event activity feed item.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, safety_event:, time:, type:, additional_properties: nil) ⇒ Samsara::Types::SafetyEventActivityFeedItemResponseBody

Parameters:

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

    Additional properties unmapped to the current class definition



43
44
45
46
47
48
49
50
# File 'lib/samsara_api/types/safety_event_activity_feed_item_response_body.rb', line 43

def initialize(id:, safety_event:, time:, type:, additional_properties: nil)
  @id = id
  @safety_event = safety_event
  @time = time
  @type = type
  @additional_properties = additional_properties
  @_field_set = { "id": id, "safetyEvent": safety_event, "time": time, "type": type }
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



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

def additional_properties
  @additional_properties
end

#id ⇒ String (readonly)

Returns The ID of the activity event feed line item.

Returns:

  • (String) —

    The ID of the activity event feed line item.



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

def id
  @id
end

#safety_event ⇒ Samsara::Types::SafetyEventObjectResponseBody (readonly)



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

def safety_event
  @safety_event
end

#time ⇒ Object (readonly)

milliseconds format.



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

def time
  @time
end

#type ⇒ Object (readonly)

CoachingStateActivityType, CreateSafetyEventActivityType



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

def type
  @type
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



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

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = parsed_json["id"]
  unless parsed_json["safetyEvent"].nil?
    safety_event = parsed_json["safetyEvent"].to_json
    safety_event = Samsara::Types::SafetyEventObjectResponseBody.from_json(json_object: safety_event)
  else
    safety_event = nil
  end
  time = parsed_json["time"]
  type = parsed_json["type"]
  new(
    id: id,
    safety_event: safety_event,
    time: time,
    type: type,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


89
90
91
92
93
94
# File 'lib/samsara_api/types/safety_event_activity_feed_item_response_body.rb', line 89

def self.validate_raw(obj:)
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  Samsara::Types::SafetyEventObjectResponseBody.validate_raw(obj: obj.safety_event)
  obj.time.is_a?(String) != false || raise("Passed value for field obj.time is not the expected type, validation failed.")
  obj.type.is_a?(Samsara::Types::SafetyEventActivityFeedItemResponseBodyType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
end

Instance Method Details

#to_json ⇒ String

Returns:

  • (String)


80
81
82
# File 'lib/samsara_api/types/safety_event_activity_feed_item_response_body.rb', line 80

def to_json
  @_field_set&.to_json
end