Class: Samsara::Types::LocationResponseResponseBody

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

Overview

Location object.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(accuracy_meters: OMIT, address: OMIT, geofence: OMIT, heading_degrees:, latitude:, longitude:, additional_properties: nil) ⇒ Samsara::Types::LocationResponseResponseBody

Parameters:

  • address (Samsara::Types::AddressResponseResponseBody) (defaults to: OMIT)
  • geofence (Samsara::Types::GeofenceResponseResponseBody) (defaults to: OMIT)
  • heading_degrees (Long) —

    Heading of the asset in degrees. May be 0 if the asset is not moving.

  • latitude (Float) —

    Latitude of the location of the asset.

  • longitude (Float) —

    Longitude of the location of the asset.

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

    Additional properties unmapped to the current class definition



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/samsara_api/types/location_response_response_body.rb', line 41

def initialize(accuracy_meters: OMIT, address: OMIT, geofence: OMIT, heading_degrees:, latitude:, longitude:, additional_properties: nil)
  @accuracy_meters = accuracy_meters if accuracy_meters != OMIT
  @address = address if address != OMIT
  @geofence = geofence if geofence != OMIT
  @heading_degrees = heading_degrees
  @latitude = latitude
  @longitude = longitude
  @additional_properties = additional_properties
  @_field_set = { "accuracyMeters": accuracy_meters, "address": address, "geofence": geofence, "headingDegrees": heading_degrees, "latitude": latitude, "longitude": longitude }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#accuracy_meters ⇒ Object (readonly)

is not available.



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

def accuracy_meters
  @accuracy_meters
end

#additional_properties ⇒ OpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct) —

    Additional properties unmapped to the current class definition



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

def additional_properties
  @additional_properties
end

#address ⇒ Samsara::Types::AddressResponseResponseBody (readonly)



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

def address
  @address
end

#geofence ⇒ Samsara::Types::GeofenceResponseResponseBody (readonly)



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

def geofence
  @geofence
end

#heading_degrees ⇒ Long (readonly)

Returns Heading of the asset in degrees. May be 0 if the asset is not moving.

Returns:

  • (Long) —

    Heading of the asset in degrees. May be 0 if the asset is not moving.



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

def heading_degrees
  @heading_degrees
end

#latitude ⇒ Float (readonly)

Returns Latitude of the location of the asset.

Returns:

  • (Float) —

    Latitude of the location of the asset.



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

def latitude
  @latitude
end

#longitude ⇒ Float (readonly)

Returns Longitude of the location of the asset.

Returns:

  • (Float) —

    Longitude of the location of the asset.



23
24
25
# File 'lib/samsara_api/types/location_response_response_body.rb', line 23

def longitude
  @longitude
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



57
58
59
60
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
# File 'lib/samsara_api/types/location_response_response_body.rb', line 57

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  accuracy_meters = parsed_json["accuracyMeters"]
  unless parsed_json["address"].nil?
    address = parsed_json["address"].to_json
    address = Samsara::Types::AddressResponseResponseBody.from_json(json_object: address)
  else
    address = nil
  end
  unless parsed_json["geofence"].nil?
    geofence = parsed_json["geofence"].to_json
    geofence = Samsara::Types::GeofenceResponseResponseBody.from_json(json_object: geofence)
  else
    geofence = nil
  end
  heading_degrees = parsed_json["headingDegrees"]
  latitude = parsed_json["latitude"]
  longitude = parsed_json["longitude"]
  new(
    accuracy_meters: accuracy_meters,
    address: address,
    geofence: geofence,
    heading_degrees: heading_degrees,
    latitude: latitude,
    longitude: longitude,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


98
99
100
101
102
103
104
105
# File 'lib/samsara_api/types/location_response_response_body.rb', line 98

def self.validate_raw(obj:)
  obj.accuracy_meters&.is_a?(Float) != false || raise("Passed value for field obj.accuracy_meters is not the expected type, validation failed.")
  obj.address.nil? || Samsara::Types::AddressResponseResponseBody.validate_raw(obj: obj.address)
  obj.geofence.nil? || Samsara::Types::GeofenceResponseResponseBody.validate_raw(obj: obj.geofence)
  obj.heading_degrees.is_a?(Long) != false || raise("Passed value for field obj.heading_degrees 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.")
end

Instance Method Details

#to_json ⇒ String

Returns:

  • (String)


89
90
91
# File 'lib/samsara_api/types/location_response_response_body.rb', line 89

def to_json
  @_field_set&.to_json
end