Class: Samsara::Types::LocationAndSpeedResponseResponseBody

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

Overview

Full location and speed objects.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(asset:, happened_at_time:, location:, speed: OMIT, additional_properties: nil) ⇒ Samsara::Types::LocationAndSpeedResponseResponseBody

Parameters:



34
35
36
37
38
39
40
41
42
43
# File 'lib/samsara_api/types/location_and_speed_response_response_body.rb', line 34

def initialize(asset:, happened_at_time:, location:, speed: OMIT, additional_properties: nil)
  @asset = asset
  @happened_at_time = happened_at_time
  @location = location
  @speed = speed if speed != OMIT
  @additional_properties = additional_properties
  @_field_set = { "asset": asset, "happenedAtTime": happened_at_time, "location": location, "speed": speed }.reject do | _k, v |
  v == OMIT
end
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



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

def additional_properties
  @additional_properties
end

#asset ⇒ Samsara::Types::AssetResponseResponseBody (readonly)



13
14
15
# File 'lib/samsara_api/types/location_and_speed_response_response_body.rb', line 13

def asset
  @asset
end

#happened_at_time ⇒ String (readonly)

Returns UTC timestamp in RFC 3339 format of the event.

Returns:

  • (String) —

    UTC timestamp in RFC 3339 format of the event.



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

def happened_at_time
  @happened_at_time
end

#location ⇒ Samsara::Types::LocationResponseResponseBody (readonly)



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

def location
  @location
end

#speed ⇒ Samsara::Types::SpeedResponseResponseBody (readonly)



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

def speed
  @speed
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/samsara_api/types/location_and_speed_response_response_body.rb', line 48

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::AssetResponseResponseBody.from_json(json_object: asset)
  else
    asset = nil
  end
  happened_at_time = parsed_json["happenedAtTime"]
  unless parsed_json["location"].nil?
    location = parsed_json["location"].to_json
    location = Samsara::Types::LocationResponseResponseBody.from_json(json_object: location)
  else
    location = nil
  end
  unless parsed_json["speed"].nil?
    speed = parsed_json["speed"].to_json
    speed = Samsara::Types::SpeedResponseResponseBody.from_json(json_object: speed)
  else
    speed = nil
  end
  new(
    asset: asset,
    happened_at_time: happened_at_time,
    location: location,
    speed: speed,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

def self.validate_raw(obj:)
  Samsara::Types::AssetResponseResponseBody.validate_raw(obj: obj.asset)
  obj.happened_at_time.is_a?(String) != false || raise("Passed value for field obj.happened_at_time is not the expected type, validation failed.")
  Samsara::Types::LocationResponseResponseBody.validate_raw(obj: obj.location)
  obj.speed.nil? || Samsara::Types::SpeedResponseResponseBody.validate_raw(obj: obj.speed)
end

Instance Method Details

#to_json ⇒ String

Returns:

  • (String)


81
82
83
# File 'lib/samsara_api/types/location_and_speed_response_response_body.rb', line 81

def to_json
  @_field_set&.to_json
end