Class: Samsara::Types::FuelCostObjectResponseBody

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

Overview

The cost incurred based on the fuel consumed during the idling event.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amount:, currency:, additional_properties: nil) ⇒ Samsara::Types::FuelCostObjectResponseBody

Parameters:

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

    Additional properties unmapped to the current class definition



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

def initialize(amount:, currency:, additional_properties: nil)
  @amount = amount
  @currency = currency
  @additional_properties = additional_properties
  @_field_set = { "amount": amount, "currency": currency }
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/fuel_cost_object_response_body.rb', line 16

def additional_properties
  @additional_properties
end

#amount ⇒ String (readonly)

Returns The money amount.

Returns:

  • (String) —

    The money amount.



11
12
13
# File 'lib/samsara_api/types/fuel_cost_object_response_body.rb', line 11

def amount
  @amount
end

#currency ⇒ Object (readonly)

usd, gbp, cad, eur, chf, mxn



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

def currency
  @currency
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



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

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

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


61
62
63
64
# File 'lib/samsara_api/types/fuel_cost_object_response_body.rb', line 61

def self.validate_raw(obj:)
  obj.amount.is_a?(String) != false || raise("Passed value for field obj.amount is not the expected type, validation failed.")
  obj.currency.is_a?(Samsara::Types::FuelCostObjectResponseBodyCurrency) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.")
end

Instance Method Details

#to_json ⇒ String

Returns:

  • (String)


52
53
54
# File 'lib/samsara_api/types/fuel_cost_object_response_body.rb', line 52

def to_json
  @_field_set&.to_json
end