Class: Samsara::Types::GrossVehicleWeight

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

Overview

returned for customers with commercial speed limits (CSL) enabled.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(unit: OMIT, weight: OMIT, additional_properties: nil) ⇒ Samsara::Types::GrossVehicleWeight

Parameters:

  • unit (Samsara::Types::GrossVehicleWeightUnit) (defaults to: OMIT) —

    The unit of weight for the vehicle.

  • weight (Long) (defaults to: OMIT) —

    The weight value of the vehicle.

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

    Additional properties unmapped to the current class definition



27
28
29
30
31
32
33
34
# File 'lib/samsara_api/types/gross_vehicle_weight.rb', line 27

def initialize(unit: OMIT, weight: OMIT, additional_properties: nil)
  @unit = unit if unit != OMIT
  @weight = weight if weight != OMIT
  @additional_properties = additional_properties
  @_field_set = { "unit": unit, "weight": weight }.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



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

def additional_properties
  @additional_properties
end

#unit ⇒ Samsara::Types::GrossVehicleWeightUnit (readonly)

Returns The unit of weight for the vehicle.

Returns:



12
13
14
# File 'lib/samsara_api/types/gross_vehicle_weight.rb', line 12

def unit
  @unit
end

#weight ⇒ Long (readonly)

Returns The weight value of the vehicle.

Returns:

  • (Long) —

    The weight value of the vehicle.



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

def weight
  @weight
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/samsara_api/types/gross_vehicle_weight.rb', line 39

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  unit = parsed_json["unit"]
  weight = parsed_json["weight"]
  new(
    unit: unit,
    weight: weight,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


62
63
64
65
# File 'lib/samsara_api/types/gross_vehicle_weight.rb', line 62

def self.validate_raw(obj:)
  obj.unit&.is_a?(Samsara::Types::GrossVehicleWeightUnit) != false || raise("Passed value for field obj.unit is not the expected type, validation failed.")
  obj.weight&.is_a?(Long) != false || raise("Passed value for field obj.weight is not the expected type, validation failed.")
end

Instance Method Details

#to_json ⇒ String

Returns:

  • (String)


53
54
55
# File 'lib/samsara_api/types/gross_vehicle_weight.rb', line 53

def to_json
  @_field_set&.to_json
end