Class: Samsara::Types::BehaviorResponseBody

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

Overview

Object reference for the behavior within the session.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(coachable_behavior_type:, coachable_events: OMIT, id:, last_coached_time:, note: OMIT, updated_at_time:, additional_properties: nil) ⇒ Samsara::Types::BehaviorResponseBody

Parameters:

  • id (String)

    Unique ID for the coaching behavior.

  • last_coached_time (DateTime)

    Time of last coached date for the same behavior label.

  • note (String) (defaults to: OMIT)

    Associated note for the coaching behavior. Returned when present.

  • updated_at_time (DateTime)

    Time of coaching behavior update in UTC.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/samsara_api/types/behavior_response_body.rb', line 77

def initialize(coachable_behavior_type:, coachable_events: OMIT, id:, last_coached_time:, note: OMIT, updated_at_time:, additional_properties: nil)
  @coachable_behavior_type = coachable_behavior_type
  @coachable_events = coachable_events if coachable_events != OMIT
  @id = id
  @last_coached_time = last_coached_time
  @note = note if note != OMIT
  @updated_at_time = updated_at_time
  @additional_properties = additional_properties
  @_field_set = { "coachableBehaviorType": coachable_behavior_type, "coachableEvents": coachable_events, "id": id, "lastCoachedTime": last_coached_time, "note": note, "updatedAtTime": updated_at_time }.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



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

def additional_properties
  @additional_properties
end

#coachable_behavior_typeObject (readonly)

‘yawControlBrakeControlActivated`, `yawControlEngineControlActivated`



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

def coachable_behavior_type
  @coachable_behavior_type
end

#coachable_eventsObject (readonly)

‘driverId,date’. Idling events - unique UUID of the event.



34
35
36
# File 'lib/samsara_api/types/behavior_response_body.rb', line 34

def coachable_events
  @coachable_events
end

#idString (readonly)

Returns Unique ID for the coaching behavior.

Returns:

  • (String)

    Unique ID for the coaching behavior.



36
37
38
# File 'lib/samsara_api/types/behavior_response_body.rb', line 36

def id
  @id
end

#last_coached_timeDateTime (readonly)

Returns Time of last coached date for the same behavior label.

Returns:

  • (DateTime)

    Time of last coached date for the same behavior label.



38
39
40
# File 'lib/samsara_api/types/behavior_response_body.rb', line 38

def last_coached_time
  @last_coached_time
end

#noteString (readonly)

Returns Associated note for the coaching behavior. Returned when present.

Returns:

  • (String)

    Associated note for the coaching behavior. Returned when present.



40
41
42
# File 'lib/samsara_api/types/behavior_response_body.rb', line 40

def note
  @note
end

#updated_at_timeDateTime (readonly)

Returns Time of coaching behavior update in UTC.

Returns:

  • (DateTime)

    Time of coaching behavior update in UTC.



42
43
44
# File 'lib/samsara_api/types/behavior_response_body.rb', line 42

def updated_at_time
  @updated_at_time
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



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
# File 'lib/samsara_api/types/behavior_response_body.rb', line 93

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  coachable_behavior_type = parsed_json["coachableBehaviorType"]
  coachable_events = parsed_json["coachableEvents"]&.map do | item |
  item = item.to_json
  Samsara::Types::CoachableEventResponseBody.from_json(json_object: item)
end
  id = parsed_json["id"]
  last_coached_time = unless parsed_json["lastCoachedTime"].nil?
  DateTime.parse(parsed_json["lastCoachedTime"])
else
  nil
end
  note = parsed_json["note"]
  updated_at_time = unless parsed_json["updatedAtTime"].nil?
  DateTime.parse(parsed_json["updatedAtTime"])
else
  nil
end
  new(
    coachable_behavior_type: coachable_behavior_type,
    coachable_events: coachable_events,
    id: id,
    last_coached_time: last_coached_time,
    note: note,
    updated_at_time: updated_at_time,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


135
136
137
138
139
140
141
142
# File 'lib/samsara_api/types/behavior_response_body.rb', line 135

def self.validate_raw(obj:)
  obj.coachable_behavior_type.is_a?(Samsara::Types::BehaviorResponseBodyCoachableBehaviorType) != false || raise("Passed value for field obj.coachable_behavior_type is not the expected type, validation failed.")
  obj.coachable_events&.is_a?(Array) != false || raise("Passed value for field obj.coachable_events 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.last_coached_time.is_a?(DateTime) != false || raise("Passed value for field obj.last_coached_time is not the expected type, validation failed.")
  obj.note&.is_a?(String) != false || raise("Passed value for field obj.note is not the expected type, validation failed.")
  obj.updated_at_time.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at_time is not the expected type, validation failed.")
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


126
127
128
# File 'lib/samsara_api/types/behavior_response_body.rb', line 126

def to_json
  @_field_set&.to_json
end