Class: Samsara::Types::VehicleLocation
- Inherits:
-
Object
- Object
- Samsara::Types::VehicleLocation
- Defined in:
- lib/samsara_api/types/vehicle_location.rb
Overview
Vehicle location event.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #heading ⇒ Float readonly
- #latitude ⇒ Float readonly
- #longitude ⇒ Float readonly
- #reverse_geo ⇒ Samsara::Types::ReverseGeo readonly
- #speed ⇒ Float readonly
- #time ⇒ String readonly
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(heading: OMIT, latitude:, longitude:, reverse_geo: OMIT, speed: OMIT, time:, additional_properties: nil) ⇒ Samsara::Types::VehicleLocation constructor
- #to_json ⇒ String
Constructor Details
#initialize(heading: OMIT, latitude:, longitude:, reverse_geo: OMIT, speed: OMIT, time:, additional_properties: nil) ⇒ Samsara::Types::VehicleLocation
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/samsara_api/types/vehicle_location.rb', line 38 def initialize(heading: OMIT, latitude:, longitude:, reverse_geo: OMIT, speed: OMIT, time:, additional_properties: nil) @heading = heading if heading != OMIT @latitude = latitude @longitude = longitude @reverse_geo = reverse_geo if reverse_geo != OMIT @speed = speed if speed != OMIT @time = time @additional_properties = additional_properties @_field_set = { "heading": heading, "latitude": latitude, "longitude": longitude, "reverseGeo": reverse_geo, "speed": speed, "time": 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.
23 24 25 |
# File 'lib/samsara_api/types/vehicle_location.rb', line 23 def additional_properties @additional_properties end |
#heading ⇒ Float (readonly)
11 12 13 |
# File 'lib/samsara_api/types/vehicle_location.rb', line 11 def heading @heading end |
#latitude ⇒ Float (readonly)
13 14 15 |
# File 'lib/samsara_api/types/vehicle_location.rb', line 13 def latitude @latitude end |
#longitude ⇒ Float (readonly)
15 16 17 |
# File 'lib/samsara_api/types/vehicle_location.rb', line 15 def longitude @longitude end |
#reverse_geo ⇒ Samsara::Types::ReverseGeo (readonly)
17 18 19 |
# File 'lib/samsara_api/types/vehicle_location.rb', line 17 def reverse_geo @reverse_geo end |
#speed ⇒ Float (readonly)
19 20 21 |
# File 'lib/samsara_api/types/vehicle_location.rb', line 19 def speed @speed end |
#time ⇒ String (readonly)
21 22 23 |
# File 'lib/samsara_api/types/vehicle_location.rb', line 21 def time @time end |
Class Method Details
.from_json(json_object:) ⇒ Samsara::Types::VehicleLocation
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/vehicle_location.rb', line 54 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) heading = parsed_json["heading"] latitude = parsed_json["latitude"] longitude = parsed_json["longitude"] unless parsed_json["reverseGeo"].nil? reverse_geo = parsed_json["reverseGeo"].to_json reverse_geo = Samsara::Types::ReverseGeo.from_json(json_object: reverse_geo) else reverse_geo = nil end speed = parsed_json["speed"] time = parsed_json["time"] new( heading: heading, latitude: latitude, longitude: longitude, reverse_geo: reverse_geo, speed: speed, time: time, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
90 91 92 93 94 95 96 97 |
# File 'lib/samsara_api/types/vehicle_location.rb', line 90 def self.validate_raw(obj:) obj.heading&.is_a?(Float) != false || raise("Passed value for field obj.heading is not the expected type, validation failed.") obj.latitude.is_a?(Float) != false || raise("Passed value for field obj.latitude is not the expected type, validation failed.") obj.longitude.is_a?(Float) != false || raise("Passed value for field obj.longitude is not the expected type, validation failed.") obj.reverse_geo.nil? || Samsara::Types::ReverseGeo.validate_raw(obj: obj.reverse_geo) obj.speed&.is_a?(Float) != false || raise("Passed value for field obj.speed is not the expected type, validation failed.") obj.time.is_a?(String) != false || raise("Passed value for field obj.time is not the expected type, validation failed.") end |
Instance Method Details
#to_json ⇒ String
81 82 83 |
# File 'lib/samsara_api/types/vehicle_location.rb', line 81 def to_json @_field_set&.to_json end |