Class: Samsara::Types::DeviceResponseResponseBody

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

Overview

connected time, and health status.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(asset:, health: OMIT, last_connected_time: OMIT, last_known_location: OMIT, model:, serial:, additional_properties: nil) ⇒ Samsara::Types::DeviceResponseResponseBody

Parameters:

  • serial (String) —

    The serial number of the device.

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

    Additional properties unmapped to the current class definition



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/samsara_api/types/device_response_response_body.rb', line 51

def initialize(asset:, health: OMIT, last_connected_time: OMIT, last_known_location: OMIT, model:, serial:, additional_properties: nil)
  @asset = asset
  @health = health if health != OMIT
  @last_connected_time = last_connected_time if last_connected_time != OMIT
  @last_known_location = last_known_location if last_known_location != OMIT
  @model = model
  @serial = serial
  @additional_properties = additional_properties
  @_field_set = { "asset": asset, "health": health, "lastConnectedTime": last_connected_time, "lastKnownLocation": last_known_location, "model": model, "serial": serial }.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



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

def additional_properties
  @additional_properties
end

#asset ⇒ Samsara::Types::DeviceAssetResponseResponseBody (readonly)



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

def asset
  @asset
end

#health ⇒ Samsara::Types::HealthResponseResponseBody (readonly)



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

def health
  @health
end

#last_connected_time ⇒ DateTime (readonly)

Returns The last time the device was connected, in RFC 3339 format.

Returns:

  • (DateTime) —

    The last time the device was connected, in RFC 3339 format.



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

def last_connected_time
  @last_connected_time
end

#last_known_location ⇒ Samsara::Types::LastKnownLocationResponseResponseBody (readonly)



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

def last_known_location
  @last_known_location
end

#model ⇒ Object (readonly)

VG55NA



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

def model
  @model
end

#serial ⇒ String (readonly)

Returns The serial number of the device.

Returns:

  • (String) —

    The serial number of the device.



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

def serial
  @serial
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/samsara_api/types/device_response_response_body.rb', line 67

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  unless parsed_json["asset"].nil?
    asset = parsed_json["asset"].to_json
    asset = Samsara::Types::DeviceAssetResponseResponseBody.from_json(json_object: asset)
  else
    asset = nil
  end
  unless parsed_json["health"].nil?
    health = parsed_json["health"].to_json
    health = Samsara::Types::HealthResponseResponseBody.from_json(json_object: health)
  else
    health = nil
  end
  last_connected_time = unless parsed_json["lastConnectedTime"].nil?
  DateTime.parse(parsed_json["lastConnectedTime"])
else
  nil
end
  unless parsed_json["lastKnownLocation"].nil?
    last_known_location = parsed_json["lastKnownLocation"].to_json
    last_known_location = Samsara::Types::LastKnownLocationResponseResponseBody.from_json(json_object: last_known_location)
  else
    last_known_location = nil
  end
  model = parsed_json["model"]
  serial = parsed_json["serial"]
  new(
    asset: asset,
    health: health,
    last_connected_time: last_connected_time,
    last_known_location: last_known_location,
    model: model,
    serial: serial,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


117
118
119
120
121
122
123
124
# File 'lib/samsara_api/types/device_response_response_body.rb', line 117

def self.validate_raw(obj:)
  Samsara::Types::DeviceAssetResponseResponseBody.validate_raw(obj: obj.asset)
  obj.health.nil? || Samsara::Types::HealthResponseResponseBody.validate_raw(obj: obj.health)
  obj.last_connected_time&.is_a?(DateTime) != false || raise("Passed value for field obj.last_connected_time is not the expected type, validation failed.")
  obj.last_known_location.nil? || Samsara::Types::LastKnownLocationResponseResponseBody.validate_raw(obj: obj.last_known_location)
  obj.model.is_a?(Samsara::Types::DeviceResponseResponseBodyModel) != false || raise("Passed value for field obj.model is not the expected type, validation failed.")
  obj.serial.is_a?(String) != false || raise("Passed value for field obj.serial is not the expected type, validation failed.")
end

Instance Method Details

#to_json ⇒ String

Returns:

  • (String)


108
109
110
# File 'lib/samsara_api/types/device_response_response_body.rb', line 108

def to_json
  @_field_set&.to_json
end