Class: Samsara::Types::TripSpeedingIntervalsResponseBody

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

Overview

TripSpeedingIntervals

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(asset:, created_at_time:, driver_id: OMIT, intervals:, trip_start_time:, updated_at_time:, additional_properties: nil) ⇒ Samsara::Types::TripSpeedingIntervalsResponseBody

Parameters:

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(asset:, created_at_time:, driver_id: OMIT, intervals:, trip_start_time:, updated_at_time:, additional_properties: nil)
  @asset = asset
  @created_at_time = created_at_time
  @driver_id = driver_id if driver_id != OMIT
  @intervals = intervals
  @trip_start_time = trip_start_time
  @updated_at_time = updated_at_time
  @additional_properties = additional_properties
  @_field_set = { "asset": asset, "createdAtTime": created_at_time, "driverId": driver_id, "intervals": intervals, "tripStartTime": trip_start_time, "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



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

def additional_properties
  @additional_properties
end

#assetSamsara::Types::TripAssetResponseBody (readonly)



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

def asset
  @asset
end

#created_at_timeString (readonly)

Returns UTC time the trip was created in Samsara in RFC 3339 format.

Returns:

  • (String)

    UTC time the trip was created in Samsara in RFC 3339 format.



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

def created_at_time
  @created_at_time
end

#driver_idObject (readonly)

true. ‘null’ if no driver id.



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

def driver_id
  @driver_id
end

#intervalsObject (readonly)

associated with the trip is always returned, empty if no intervals exist.



20
21
22
# File 'lib/samsara_api/types/trip_speeding_intervals_response_body.rb', line 20

def intervals
  @intervals
end

#trip_start_timeString (readonly)

Returns UTC time the trip started in RFC 3339 format.

Returns:

  • (String)

    UTC time the trip started in RFC 3339 format.



22
23
24
# File 'lib/samsara_api/types/trip_speeding_intervals_response_body.rb', line 22

def trip_start_time
  @trip_start_time
end

#updated_at_timeObject (readonly)

are when trip’s endTime populates or interval.isDismissed changes value.



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

def updated_at_time
  @updated_at_time
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



61
62
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
# File 'lib/samsara_api/types/trip_speeding_intervals_response_body.rb', line 61

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  unless parsed_json["asset"].nil?
    asset = parsed_json["asset"].to_json
    asset = Samsara::Types::TripAssetResponseBody.from_json(json_object: asset)
  else
    asset = nil
  end
  created_at_time = parsed_json["createdAtTime"]
  driver_id = parsed_json["driverId"]
  intervals = parsed_json["intervals"]&.map do | item |
  item = item.to_json
  Samsara::Types::SpeedingIntervalResponseBody.from_json(json_object: item)
end
  trip_start_time = parsed_json["tripStartTime"]
  updated_at_time = parsed_json["updatedAtTime"]
  new(
    asset: asset,
    created_at_time: created_at_time,
    driver_id: driver_id,
    intervals: intervals,
    trip_start_time: trip_start_time,
    updated_at_time: updated_at_time,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


100
101
102
103
104
105
106
107
# File 'lib/samsara_api/types/trip_speeding_intervals_response_body.rb', line 100

def self.validate_raw(obj:)
  Samsara::Types::TripAssetResponseBody.validate_raw(obj: obj.asset)
  obj.created_at_time.is_a?(String) != false || raise("Passed value for field obj.created_at_time is not the expected type, validation failed.")
  obj.driver_id&.is_a?(String) != false || raise("Passed value for field obj.driver_id is not the expected type, validation failed.")
  obj.intervals.is_a?(Array) != false || raise("Passed value for field obj.intervals is not the expected type, validation failed.")
  obj.trip_start_time.is_a?(String) != false || raise("Passed value for field obj.trip_start_time is not the expected type, validation failed.")
  obj.updated_at_time.is_a?(String) != 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)


91
92
93
# File 'lib/samsara_api/types/trip_speeding_intervals_response_body.rb', line 91

def to_json
  @_field_set&.to_json
end