Class: Samsara::Types::Address

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

Overview

An Address object.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address_types: OMIT, contacts: OMIT, created_at_time: OMIT, external_ids: OMIT, formatted_address:, geofence:, id:, latitude: OMIT, longitude: OMIT, name:, notes: OMIT, tags: OMIT, additional_properties: nil) ⇒ Samsara::Types::Address

Parameters:

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

    Additional properties unmapped to the current class definition



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/samsara_api/types/address.rb', line 75

def initialize(address_types: OMIT, contacts: OMIT, created_at_time: OMIT, external_ids: OMIT, formatted_address:, geofence:, id:, latitude: OMIT, longitude: OMIT, name:, notes: OMIT, tags: OMIT, additional_properties: nil)
  @address_types = address_types if address_types != OMIT
  @contacts = contacts if contacts != OMIT
  @created_at_time = created_at_time if created_at_time != OMIT
  @external_ids = external_ids if external_ids != OMIT
  @formatted_address = formatted_address
  @geofence = geofence
  @id = id
  @latitude = latitude if latitude != OMIT
  @longitude = longitude if longitude != OMIT
  @name = name
  @notes = notes if notes != OMIT
  @tags = tags if tags != OMIT
  @additional_properties = additional_properties
  @_field_set = { "addressTypes": address_types, "contacts": contacts, "createdAtTime": created_at_time, "externalIds": external_ids, "formattedAddress": formatted_address, "geofence": geofence, "id": id, "latitude": latitude, "longitude": longitude, "name": name, "notes": notes, "tags": tags }.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



47
48
49
# File 'lib/samsara_api/types/address.rb', line 47

def additional_properties
  @additional_properties
end

#address_types ⇒ Object (readonly)

industrialSite, alertsOnly, agricultureSource.



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

def address_types
  @address_types
end

#contacts ⇒ Array<Samsara::Types::ContactTinyResponse> (readonly)

Returns An array Contact mini-objects that are associated the Address.

Returns:



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

def contacts
  @contacts
end

#created_at_time ⇒ DateTime (readonly)

Returns The date and time this address was created in RFC 3339 format.

Returns:

  • (DateTime) —

    The date and time this address was created in RFC 3339 format.



22
23
24
# File 'lib/samsara_api/types/address.rb', line 22

def created_at_time
  @created_at_time
end

#external_ids ⇒ Object (readonly)

given object.



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

def external_ids
  @external_ids
end

#formatted_address ⇒ Object (readonly)

Google Maps.



28
29
30
# File 'lib/samsara_api/types/address.rb', line 28

def formatted_address
  @formatted_address
end

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



30
31
32
# File 'lib/samsara_api/types/address.rb', line 30

def geofence
  @geofence
end

#id ⇒ String (readonly)

Returns ID of the Address.

Returns:

  • (String) —

    ID of the Address.



32
33
34
# File 'lib/samsara_api/types/address.rb', line 32

def id
  @id
end

#latitude ⇒ Object (readonly)

provided.



35
36
37
# File 'lib/samsara_api/types/address.rb', line 35

def latitude
  @latitude
end

#longitude ⇒ Object (readonly)

provided.



38
39
40
# File 'lib/samsara_api/types/address.rb', line 38

def longitude
  @longitude
end

#name ⇒ String (readonly)

Returns Name of the address.

Returns:

  • (String) —

    Name of the address.



40
41
42
# File 'lib/samsara_api/types/address.rb', line 40

def name
  @name
end

#notes ⇒ String (readonly)

Returns Notes about the address.

Returns:

  • (String) —

    Notes about the address.



42
43
44
# File 'lib/samsara_api/types/address.rb', line 42

def notes
  @notes
end

#tags ⇒ Object (readonly)

entry.



45
46
47
# File 'lib/samsara_api/types/address.rb', line 45

def tags
  @tags
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/samsara_api/types/address.rb', line 97

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  address_types = parsed_json["addressTypes"]
  contacts = parsed_json["contacts"]&.map do | item |
  item = item.to_json
  Samsara::Types::ContactTinyResponse.from_json(json_object: item)
end
  created_at_time = unless parsed_json["createdAtTime"].nil?
  DateTime.parse(parsed_json["createdAtTime"])
else
  nil
end
  external_ids = parsed_json["externalIds"]
  formatted_address = parsed_json["formattedAddress"]
  unless parsed_json["geofence"].nil?
    geofence = parsed_json["geofence"].to_json
    geofence = Samsara::Types::AddressGeofence.from_json(json_object: geofence)
  else
    geofence = nil
  end
  id = parsed_json["id"]
  latitude = parsed_json["latitude"]
  longitude = parsed_json["longitude"]
  name = parsed_json["name"]
  notes = parsed_json["notes"]
  tags = parsed_json["tags"]&.map do | item |
  item = item.to_json
  Samsara::Types::TagTinyResponse.from_json(json_object: item)
end
  new(
    address_types: address_types,
    contacts: contacts,
    created_at_time: created_at_time,
    external_ids: external_ids,
    formatted_address: formatted_address,
    geofence: geofence,
    id: id,
    latitude: latitude,
    longitude: longitude,
    name: name,
    notes: notes,
    tags: tags,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/samsara_api/types/address.rb', line 155

def self.validate_raw(obj:)
  obj.address_types&.is_a?(Array) != false || raise("Passed value for field obj.address_types is not the expected type, validation failed.")
  obj.contacts&.is_a?(Array) != false || raise("Passed value for field obj.contacts is not the expected type, validation failed.")
  obj.created_at_time&.is_a?(DateTime) != false || raise("Passed value for field obj.created_at_time 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.formatted_address.is_a?(String) != false || raise("Passed value for field obj.formatted_address is not the expected type, validation failed.")
  Samsara::Types::AddressGeofence.validate_raw(obj: obj.geofence)
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id 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.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.notes&.is_a?(String) != false || raise("Passed value for field obj.notes is not the expected type, validation failed.")
  obj.tags&.is_a?(Array) != false || raise("Passed value for field obj.tags is not the expected type, validation failed.")
end

Instance Method Details

#to_json ⇒ String

Returns:

  • (String)


146
147
148
# File 'lib/samsara_api/types/address.rb', line 146

def to_json
  @_field_set&.to_json
end