Class: Samsara::Types::BehaviorResponseBody
- Inherits:
-
Object
- Object
- Samsara::Types::BehaviorResponseBody
- 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
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#coachable_behavior_type ⇒ Object
readonly
‘yawControlBrakeControlActivated`, `yawControlEngineControlActivated`.
-
#coachable_events ⇒ Object
readonly
‘driverId,date’.
-
#id ⇒ String
readonly
Unique ID for the coaching behavior.
-
#last_coached_time ⇒ DateTime
readonly
Time of last coached date for the same behavior label.
-
#note ⇒ String
readonly
Associated note for the coaching behavior.
-
#updated_at_time ⇒ DateTime
readonly
Time of coaching behavior update in UTC.
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(coachable_behavior_type:, coachable_events: OMIT, id:, last_coached_time:, note: OMIT, updated_at_time:, additional_properties: nil) ⇒ Samsara::Types::BehaviorResponseBody constructor
- #to_json ⇒ String
Constructor Details
#initialize(coachable_behavior_type:, coachable_events: OMIT, id:, last_coached_time:, note: OMIT, updated_at_time:, additional_properties: nil) ⇒ Samsara::Types::BehaviorResponseBody
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_properties ⇒ OpenStruct (readonly)
Returns 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_type ⇒ Object (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_events ⇒ Object (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 |
#id ⇒ String (readonly)
Returns 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_time ⇒ DateTime (readonly)
Returns 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 |
#note ⇒ String (readonly)
Returns 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_time ⇒ DateTime (readonly)
Returns 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
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
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_json ⇒ String
126 127 128 |
# File 'lib/samsara_api/types/behavior_response_body.rb', line 126 def to_json @_field_set&.to_json end |