Class: Samsara::Types::EquipmentObject
- Inherits:
-
Object
- Object
- Samsara::Types::EquipmentObject
- Defined in:
- lib/samsara_api/types/equipment_object.rb
Overview
An equipment object.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#asset_serial ⇒ String
readonly
An equipment identification number.
- #external_ids ⇒ Samsara::Types::CARRIER_PROPOSED_ASSIGNMENT_DRIVER_ALL_OF_2_EXTERNAL_IDS readonly
- #id ⇒ String readonly
- #installed_gateway ⇒ Samsara::Types::EquipmentInstalledGateway readonly
- #name ⇒ String readonly
-
#notes ⇒ String
readonly
Notes about a piece of equipment.
-
#tags ⇒ Array<Samsara::Types::TagTinyResponse>
readonly
An array of all tag mini-objects that are associated with the given equipment.
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(asset_serial: OMIT, external_ids: OMIT, id:, installed_gateway: OMIT, name: OMIT, notes: OMIT, tags: OMIT, additional_properties: nil) ⇒ Samsara::Types::EquipmentObject constructor
- #to_json ⇒ String
Constructor Details
#initialize(asset_serial: OMIT, external_ids: OMIT, id:, installed_gateway: OMIT, name: OMIT, notes: OMIT, tags: OMIT, additional_properties: nil) ⇒ Samsara::Types::EquipmentObject
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/samsara_api/types/equipment_object.rb', line 43 def initialize(asset_serial: OMIT, external_ids: OMIT, id:, installed_gateway: OMIT, name: OMIT, notes: OMIT, tags: OMIT, additional_properties: nil) @asset_serial = asset_serial if asset_serial != OMIT @external_ids = external_ids if external_ids != OMIT @id = id @installed_gateway = installed_gateway if installed_gateway != OMIT @name = name if name != OMIT @notes = notes if notes != OMIT @tags = if != OMIT @additional_properties = additional_properties @_field_set = { "assetSerial": asset_serial, "externalIds": external_ids, "id": id, "installedGateway": installed_gateway, "name": name, "notes": notes, "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.
27 28 29 |
# File 'lib/samsara_api/types/equipment_object.rb', line 27 def additional_properties @additional_properties end |
#asset_serial ⇒ String (readonly)
Returns An equipment identification number.
13 14 15 |
# File 'lib/samsara_api/types/equipment_object.rb', line 13 def asset_serial @asset_serial end |
#external_ids ⇒ Samsara::Types::CARRIER_PROPOSED_ASSIGNMENT_DRIVER_ALL_OF_2_EXTERNAL_IDS (readonly)
15 16 17 |
# File 'lib/samsara_api/types/equipment_object.rb', line 15 def external_ids @external_ids end |
#id ⇒ String (readonly)
17 18 19 |
# File 'lib/samsara_api/types/equipment_object.rb', line 17 def id @id end |
#installed_gateway ⇒ Samsara::Types::EquipmentInstalledGateway (readonly)
19 20 21 |
# File 'lib/samsara_api/types/equipment_object.rb', line 19 def installed_gateway @installed_gateway end |
#name ⇒ String (readonly)
21 22 23 |
# File 'lib/samsara_api/types/equipment_object.rb', line 21 def name @name end |
#notes ⇒ String (readonly)
Returns Notes about a piece of equipment. Samsara supports a maximum of 255 chars.
23 24 25 |
# File 'lib/samsara_api/types/equipment_object.rb', line 23 def notes @notes end |
#tags ⇒ Array<Samsara::Types::TagTinyResponse> (readonly)
Returns An array of all tag mini-objects that are associated with the given equipment.
25 26 27 |
# File 'lib/samsara_api/types/equipment_object.rb', line 25 def @tags end |
Class Method Details
.from_json(json_object:) ⇒ Samsara::Types::EquipmentObject
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 86 87 88 |
# File 'lib/samsara_api/types/equipment_object.rb', line 60 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) asset_serial = parsed_json["assetSerial"] external_ids = parsed_json["externalIds"] id = parsed_json["id"] unless parsed_json["installedGateway"].nil? installed_gateway = parsed_json["installedGateway"].to_json installed_gateway = Samsara::Types::EquipmentInstalledGateway.from_json(json_object: installed_gateway) else installed_gateway = nil end name = parsed_json["name"] notes = parsed_json["notes"] = parsed_json["tags"]&.map do | item | item = item.to_json Samsara::Types::TagTinyResponse.from_json(json_object: item) end new( asset_serial: asset_serial, external_ids: external_ids, id: id, installed_gateway: installed_gateway, name: name, notes: notes, tags: , additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
101 102 103 104 105 106 107 108 109 |
# File 'lib/samsara_api/types/equipment_object.rb', line 101 def self.validate_raw(obj:) obj.asset_serial&.is_a?(String) != false || raise("Passed value for field obj.asset_serial 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.installed_gateway.nil? || Samsara::Types::EquipmentInstalledGateway.validate_raw(obj: obj.installed_gateway) 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.&.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
92 93 94 |
# File 'lib/samsara_api/types/equipment_object.rb', line 92 def to_json @_field_set&.to_json end |