Class: Samsara::Types::IdlingEventObjectResponseBody

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

Overview

An idling event object.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address_id: OMIT, address_type: OMIT, air_temperature_millicelsius: OMIT, asset_id:, duration_milliseconds:, event_uuid:, fuel_consumed_milliliters:, fuel_cost:, gaseous_fuel_consumed_grams:, gaseous_fuel_cost:, operator_id: OMIT, pto_state:, start_time:, additional_properties: nil) ⇒ Samsara::Types::IdlingEventObjectResponseBody

Parameters:

  • start_time (String) —

    The start time of the idling event in RFC 3339 format.

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

    Additional properties unmapped to the current class definition



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

def initialize(address_id: OMIT, address_type: OMIT, air_temperature_millicelsius: OMIT, asset_id:, duration_milliseconds:, event_uuid:, fuel_consumed_milliliters:, fuel_cost:, gaseous_fuel_consumed_grams:, gaseous_fuel_cost:, operator_id: OMIT, pto_state:, start_time:, additional_properties: nil)
  @address_id = address_id if address_id != OMIT
  @address_type = address_type if address_type != OMIT
  @air_temperature_millicelsius = air_temperature_millicelsius if air_temperature_millicelsius != OMIT
  @asset_id = asset_id
  @duration_milliseconds = duration_milliseconds
  @event_uuid = event_uuid
  @fuel_consumed_milliliters = fuel_consumed_milliliters
  @fuel_cost = fuel_cost
  @gaseous_fuel_consumed_grams = gaseous_fuel_consumed_grams
  @gaseous_fuel_cost = gaseous_fuel_cost
  @operator_id = operator_id if operator_id != OMIT
  @pto_state = pto_state
  @start_time = start_time
  @additional_properties = additional_properties
  @_field_set = { "addressId": address_id, "addressType": address_type, "airTemperatureMillicelsius": air_temperature_millicelsius, "assetId": asset_id, "durationMilliseconds": duration_milliseconds, "eventUuid": event_uuid, "fuelConsumedMilliliters": fuel_consumed_milliliters, "fuelCost": fuel_cost, "gaseousFuelConsumedGrams": gaseous_fuel_consumed_grams, "gaseousFuelCost": gaseous_fuel_cost, "operatorId": operator_id, "ptoState": pto_state, "startTime": start_time }.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



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

def additional_properties
  @additional_properties
end

#address_id ⇒ Object (readonly)

the address at the time of idling.



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

def address_id
  @address_id
end

#address_type ⇒ Object (readonly)

shortHaul, undefined, workforceSite, yard



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

def address_type
  @address_type
end

#air_temperature_millicelsius ⇒ Object (readonly)

only when it is known.



21
22
23
# File 'lib/samsara_api/types/idling_event_object_response_body.rb', line 21

def air_temperature_millicelsius
  @air_temperature_millicelsius
end

#asset_id ⇒ Long (readonly)

Returns Samsara ID of the asset assigned to the event. Returns vehicle ID at this time.

Returns:

  • (Long) —

    Samsara ID of the asset assigned to the event. Returns vehicle ID at this time.



23
24
25
# File 'lib/samsara_api/types/idling_event_object_response_body.rb', line 23

def asset_id
  @asset_id
end

#duration_milliseconds ⇒ Long (readonly)

Returns The duration of the idling event in milliseconds.

Returns:

  • (Long) —

    The duration of the idling event in milliseconds.



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

def duration_milliseconds
  @duration_milliseconds
end

#event_uuid ⇒ String (readonly)

Returns Universally unique identifier of the idling event.

Returns:

  • (String) —

    Universally unique identifier of the idling event.



27
28
29
# File 'lib/samsara_api/types/idling_event_object_response_body.rb', line 27

def event_uuid
  @event_uuid
end

#fuel_consumed_milliliters ⇒ Float (readonly)

Returns The amount of fuel consumed in milliliters during the idling event.

Returns:

  • (Float) —

    The amount of fuel consumed in milliliters during the idling event.



29
30
31
# File 'lib/samsara_api/types/idling_event_object_response_body.rb', line 29

def fuel_consumed_milliliters
  @fuel_consumed_milliliters
end

#fuel_cost ⇒ Samsara::Types::FuelCostObjectResponseBody (readonly)



31
32
33
# File 'lib/samsara_api/types/idling_event_object_response_body.rb', line 31

def fuel_cost
  @fuel_cost
end

#gaseous_fuel_consumed_grams ⇒ Float (readonly)

Returns The amount of gaseous fuel consumed in grams during the idling event.

Returns:

  • (Float) —

    The amount of gaseous fuel consumed in grams during the idling event.



33
34
35
# File 'lib/samsara_api/types/idling_event_object_response_body.rb', line 33

def gaseous_fuel_consumed_grams
  @gaseous_fuel_consumed_grams
end

#gaseous_fuel_cost ⇒ Samsara::Types::GaseousFuelCostObjectResponseBody (readonly)



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

def gaseous_fuel_cost
  @gaseous_fuel_cost
end

#operator_id ⇒ Object (readonly)

Value is returned when the driver is assigned to the vehicle.



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

def operator_id
  @operator_id
end

#pto_state ⇒ Object (readonly)

inactive`



41
42
43
# File 'lib/samsara_api/types/idling_event_object_response_body.rb', line 41

def pto_state
  @pto_state
end

#start_time ⇒ String (readonly)

Returns The start time of the idling event in RFC 3339 format.

Returns:

  • (String) —

    The start time of the idling event in RFC 3339 format.



43
44
45
# File 'lib/samsara_api/types/idling_event_object_response_body.rb', line 43

def start_time
  @start_time
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



96
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
# File 'lib/samsara_api/types/idling_event_object_response_body.rb', line 96

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  address_id = parsed_json["addressId"]
  address_type = parsed_json["addressType"]
  air_temperature_millicelsius = parsed_json["airTemperatureMillicelsius"]
  asset_id = parsed_json["assetId"]
  duration_milliseconds = parsed_json["durationMilliseconds"]
  event_uuid = parsed_json["eventUuid"]
  fuel_consumed_milliliters = parsed_json["fuelConsumedMilliliters"]
  unless parsed_json["fuelCost"].nil?
    fuel_cost = parsed_json["fuelCost"].to_json
    fuel_cost = Samsara::Types::FuelCostObjectResponseBody.from_json(json_object: fuel_cost)
  else
    fuel_cost = nil
  end
  gaseous_fuel_consumed_grams = parsed_json["gaseousFuelConsumedGrams"]
  unless parsed_json["gaseousFuelCost"].nil?
    gaseous_fuel_cost = parsed_json["gaseousFuelCost"].to_json
    gaseous_fuel_cost = Samsara::Types::GaseousFuelCostObjectResponseBody.from_json(json_object: gaseous_fuel_cost)
  else
    gaseous_fuel_cost = nil
  end
  operator_id = parsed_json["operatorId"]
  pto_state = parsed_json["ptoState"]
  start_time = parsed_json["startTime"]
  new(
    address_id: address_id,
    address_type: address_type,
    air_temperature_millicelsius: air_temperature_millicelsius,
    asset_id: asset_id,
    duration_milliseconds: duration_milliseconds,
    event_uuid: event_uuid,
    fuel_consumed_milliliters: fuel_consumed_milliliters,
    fuel_cost: fuel_cost,
    gaseous_fuel_consumed_grams: gaseous_fuel_consumed_grams,
    gaseous_fuel_cost: gaseous_fuel_cost,
    operator_id: operator_id,
    pto_state: pto_state,
    start_time: start_time,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/samsara_api/types/idling_event_object_response_body.rb', line 151

def self.validate_raw(obj:)
  obj.address_id&.is_a?(String) != false || raise("Passed value for field obj.address_id is not the expected type, validation failed.")
  obj.address_type&.is_a?(Samsara::Types::IdlingEventObjectResponseBodyAddressType) != false || raise("Passed value for field obj.address_type is not the expected type, validation failed.")
  obj.air_temperature_millicelsius&.is_a?(Long) != false || raise("Passed value for field obj.air_temperature_millicelsius is not the expected type, validation failed.")
  obj.asset_id.is_a?(Long) != false || raise("Passed value for field obj.asset_id is not the expected type, validation failed.")
  obj.duration_milliseconds.is_a?(Long) != false || raise("Passed value for field obj.duration_milliseconds is not the expected type, validation failed.")
  obj.event_uuid.is_a?(String) != false || raise("Passed value for field obj.event_uuid is not the expected type, validation failed.")
  obj.fuel_consumed_milliliters.is_a?(Float) != false || raise("Passed value for field obj.fuel_consumed_milliliters is not the expected type, validation failed.")
  Samsara::Types::FuelCostObjectResponseBody.validate_raw(obj: obj.fuel_cost)
  obj.gaseous_fuel_consumed_grams.is_a?(Float) != false || raise("Passed value for field obj.gaseous_fuel_consumed_grams is not the expected type, validation failed.")
  Samsara::Types::GaseousFuelCostObjectResponseBody.validate_raw(obj: obj.gaseous_fuel_cost)
  obj.operator_id&.is_a?(Long) != false || raise("Passed value for field obj.operator_id is not the expected type, validation failed.")
  obj.pto_state.is_a?(String) != false || raise("Passed value for field obj.pto_state is not the expected type, validation failed.")
  obj.start_time.is_a?(String) != false || raise("Passed value for field obj.start_time is not the expected type, validation failed.")
end

Instance Method Details

#to_json ⇒ String

Returns:

  • (String)


142
143
144
# File 'lib/samsara_api/types/idling_event_object_response_body.rb', line 142

def to_json
  @_field_set&.to_json
end