Class: Samsara::Types::FormsGeofenceObjectResponseBody

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

Overview

Tracked or untracked (i.e. manually entered) geofence object.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address: OMIT, entry_type:, external_ids: OMIT, id: OMIT, name: OMIT, additional_properties: nil) ⇒ Samsara::Types::FormsGeofenceObjectResponseBody

Parameters:

  • address (String) (defaults to: OMIT) —

    Address of the geofence. Included if 'entryType' is tracked.

  • entry_type (Samsara::Types::FormsGeofenceObjectResponseBodyEntryType) —

    The type of entry for the geofence. Valid values: tracked, untracked

  • external_ids (Hash{String => String}) (defaults to: OMIT) —

    A map of external ids

  • id (String) (defaults to: OMIT) —

    ID of the tracked geofence. Included if 'entryType' is tracked.

  • name (String) (defaults to: OMIT) —

    Name of an untracked (i.e. manually entered) geofence.

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

    Additional properties unmapped to the current class definition



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

def initialize(address: OMIT, entry_type:, external_ids: OMIT, id: OMIT, name: OMIT, additional_properties: nil)
  @address = address if address != OMIT
  @entry_type = entry_type
  @external_ids = external_ids if external_ids != OMIT
  @id = id if id != OMIT
  @name = name if name != OMIT
  @additional_properties = additional_properties
  @_field_set = { "address": address, "entryType": entry_type, "externalIds": external_ids, "id": id, "name": name }.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/forms_geofence_object_response_body.rb', line 21

def additional_properties
  @additional_properties
end

#address ⇒ String (readonly)

Returns Address of the geofence. Included if 'entryType' is tracked.

Returns:

  • (String) —

    Address of the geofence. Included if 'entryType' is tracked.



11
12
13
# File 'lib/samsara_api/types/forms_geofence_object_response_body.rb', line 11

def address
  @address
end

#entry_type ⇒ Samsara::Types::FormsGeofenceObjectResponseBodyEntryType (readonly)

Returns The type of entry for the geofence. Valid values: tracked, untracked.

Returns:



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

def entry_type
  @entry_type
end

#external_ids ⇒ Hash{String => String} (readonly)

Returns A map of external ids.

Returns:

  • (Hash{String => String}) —

    A map of external ids



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

def external_ids
  @external_ids
end

#id ⇒ String (readonly)

Returns ID of the tracked geofence. Included if 'entryType' is tracked.

Returns:

  • (String) —

    ID of the tracked geofence. Included if 'entryType' is tracked.



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

def id
  @id
end

#name ⇒ String (readonly)

Returns Name of an untracked (i.e. manually entered) geofence.

Returns:

  • (String) —

    Name of an untracked (i.e. manually entered) geofence.



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

def name
  @name
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



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

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  address = parsed_json["address"]
  entry_type = parsed_json["entryType"]
  external_ids = parsed_json["externalIds"]
  id = parsed_json["id"]
  name = parsed_json["name"]
  new(
    address: address,
    entry_type: entry_type,
    external_ids: external_ids,
    id: id,
    name: name,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

def self.validate_raw(obj:)
  obj.address&.is_a?(String) != false || raise("Passed value for field obj.address is not the expected type, validation failed.")
  obj.entry_type.is_a?(Samsara::Types::FormsGeofenceObjectResponseBodyEntryType) != false || raise("Passed value for field obj.entry_type is not the expected type, validation failed.")
  obj.external_ids&.is_a?(Hash) != false || raise("Passed value for field obj.external_ids is not the expected type, validation failed.")
  obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
end

Instance Method Details

#to_json ⇒ String

Returns:

  • (String)


70
71
72
# File 'lib/samsara_api/types/forms_geofence_object_response_body.rb', line 70

def to_json
  @_field_set&.to_json
end