Class: Samsara::Types::AddressGeofence

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

Overview

circle or a polygon, but not both.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(circle: OMIT, polygon: OMIT, settings: OMIT, additional_properties: nil) ⇒ Samsara::Types::AddressGeofence



32
33
34
35
36
37
38
39
40
# File 'lib/samsara_api/types/address_geofence.rb', line 32

def initialize(circle: OMIT, polygon: OMIT, settings: OMIT, additional_properties: nil)
  @circle = circle if circle != OMIT
  @polygon = polygon if polygon != OMIT
  @settings = settings if settings != OMIT
  @additional_properties = additional_properties
  @_field_set = { "circle": circle, "polygon": polygon, "settings": settings }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_properties ⇒ OpenStruct (readonly)



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

def additional_properties
  @additional_properties
end

#circle ⇒ Samsara::Types::AddressGeofenceCircle (readonly)



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

def circle
  @circle
end

#polygon ⇒ Samsara::Types::AddressGeofencePolygon (readonly)



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

def polygon
  @polygon
end

#settings ⇒ Samsara::Types::AddressGeofenceSettings (readonly)



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

def settings
  @settings
end

Class Method Details

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



45
46
47
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
# File 'lib/samsara_api/types/address_geofence.rb', line 45

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  unless parsed_json["circle"].nil?
    circle = parsed_json["circle"].to_json
    circle = Samsara::Types::AddressGeofenceCircle.from_json(json_object: circle)
  else
    circle = nil
  end
  unless parsed_json["polygon"].nil?
    polygon = parsed_json["polygon"].to_json
    polygon = Samsara::Types::AddressGeofencePolygon.from_json(json_object: polygon)
  else
    polygon = nil
  end
  unless parsed_json["settings"].nil?
    settings = parsed_json["settings"].to_json
    settings = Samsara::Types::AddressGeofenceSettings.from_json(json_object: settings)
  else
    settings = nil
  end
  new(
    circle: circle,
    polygon: polygon,
    settings: settings,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void



85
86
87
88
89
# File 'lib/samsara_api/types/address_geofence.rb', line 85

def self.validate_raw(obj:)
  obj.circle.nil? || Samsara::Types::AddressGeofenceCircle.validate_raw(obj: obj.circle)
  obj.polygon.nil? || Samsara::Types::AddressGeofencePolygon.validate_raw(obj: obj.polygon)
  obj.settings.nil? || Samsara::Types::AddressGeofenceSettings.validate_raw(obj: obj.settings)
end

Instance Method Details

#to_json ⇒ String



76
77
78
# File 'lib/samsara_api/types/address_geofence.rb', line 76

def to_json
  @_field_set&.to_json
end