Class: Samsara::Types::FormsDateTimeValueObjectResponseBody

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

Overview

The value of a datetime form input field.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, value:, additional_properties: nil) ⇒ Samsara::Types::FormsDateTimeValueObjectResponseBody

Parameters:

  • type (Samsara::Types::FormsDateTimeValueObjectResponseBodyType)

    The type of datetime format. Valid values: ‘datetime`, `date`, `time`

  • value (DateTime)

    UTC timestamp in RFC 3339 format.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(type:, value:, additional_properties: nil)
  @type = type
  @value = value
  @additional_properties = additional_properties
  @_field_set = { "type": type, "value": value }
end

Instance Attribute Details

#additional_propertiesOpenStruct (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/forms_date_time_value_object_response_body.rb', line 16

def additional_properties
  @additional_properties
end

#typeSamsara::Types::FormsDateTimeValueObjectResponseBodyType (readonly)

Returns The type of datetime format. Valid values: ‘datetime`, `date`, `time`.

Returns:



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

def type
  @type
end

#valueDateTime (readonly)

Returns UTC timestamp in RFC 3339 format.

Returns:

  • (DateTime)

    UTC timestamp in RFC 3339 format.



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

def value
  @value
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/samsara_api/types/forms_date_time_value_object_response_body.rb', line 37

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  type = parsed_json["type"]
  value = unless parsed_json["value"].nil?
  DateTime.parse(parsed_json["value"])
else
  nil
end
  new(
    type: type,
    value: value,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


64
65
66
67
# File 'lib/samsara_api/types/forms_date_time_value_object_response_body.rb', line 64

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

Instance Method Details

#to_jsonString

Returns:

  • (String)


55
56
57
# File 'lib/samsara_api/types/forms_date_time_value_object_response_body.rb', line 55

def to_json
  @_field_set&.to_json
end