Class: Samsara::Types::EquipmentLocation

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

Overview

Location reading.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(heading: OMIT, latitude:, longitude:, speed: OMIT, time:, additional_properties: nil) ⇒ Samsara::Types::EquipmentLocation

Parameters:

  • heading (Float) (defaults to: OMIT) —

    Heading of the unit of equipment in degrees.

  • latitude (Float) —

    GPS latitude represented in degrees

  • longitude (Float) —

    GPS longitude represented in degrees

  • speed (Float) (defaults to: OMIT) —

    GPS speed of the unit of equipment in miles per hour.

  • time (String)
  • additional_properties (OpenStruct) (defaults to: nil) —

    Additional properties unmapped to the current class definition



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

def initialize(heading: OMIT, latitude:, longitude:, speed: OMIT, time:, additional_properties: nil)
  @heading = heading if heading != OMIT
  @latitude = latitude
  @longitude = longitude
  @speed = speed if speed != OMIT
  @time = time
  @additional_properties = additional_properties
  @_field_set = { "heading": heading, "latitude": latitude, "longitude": longitude, "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.

Returns:

  • (OpenStruct) —

    Additional properties unmapped to the current class definition



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

def additional_properties
  @additional_properties
end

#heading ⇒ Float (readonly)

Returns Heading of the unit of equipment in degrees.

Returns:

  • (Float) —

    Heading of the unit of equipment in degrees.



10
11
12
# File 'lib/samsara_api/types/equipment_location.rb', line 10

def heading
  @heading
end

#latitude ⇒ Float (readonly)

Returns GPS latitude represented in degrees.

Returns:

  • (Float) —

    GPS latitude represented in degrees



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

def latitude
  @latitude
end

#longitude ⇒ Float (readonly)

Returns GPS longitude represented in degrees.

Returns:

  • (Float) —

    GPS longitude represented in degrees



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

def longitude
  @longitude
end

#speed ⇒ Float (readonly)

Returns GPS speed of the unit of equipment in miles per hour.

Returns:

  • (Float) —

    GPS speed of the unit of equipment in miles per hour.



16
17
18
# File 'lib/samsara_api/types/equipment_location.rb', line 16

def speed
  @speed
end

#time ⇒ String (readonly)

Returns:

  • (String)


18
19
20
# File 'lib/samsara_api/types/equipment_location.rb', line 18

def time
  @time
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/samsara_api/types/equipment_location.rb', line 49

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"]
  speed = parsed_json["speed"]
  time = parsed_json["time"]
  new(
    heading: heading,
    latitude: latitude,
    longitude: longitude,
    speed: speed,
    time: time,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


78
79
80
81
82
83
84
# File 'lib/samsara_api/types/equipment_location.rb', line 78

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.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

Returns:

  • (String)


69
70
71
# File 'lib/samsara_api/types/equipment_location.rb', line 69

def to_json
  @_field_set&.to_json
end