Class: Samsara::Types::FormsDateTimeValueObjectResponseBody
- Inherits:
-
Object
- Object
- Samsara::Types::FormsDateTimeValueObjectResponseBody
- 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
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#type ⇒ Samsara::Types::FormsDateTimeValueObjectResponseBodyType
readonly
The type of datetime format.
-
#value ⇒ DateTime
readonly
UTC timestamp in RFC 3339 format.
Class Method Summary collapse
- .from_json(json_object:) ⇒ Samsara::Types::FormsDateTimeValueObjectResponseBody
- .validate_raw(obj:) ⇒ Void
Instance Method Summary collapse
- #initialize(type:, value:, additional_properties: nil) ⇒ Samsara::Types::FormsDateTimeValueObjectResponseBody constructor
- #to_json ⇒ String
Constructor Details
#initialize(type:, value:, additional_properties: nil) ⇒ Samsara::Types::FormsDateTimeValueObjectResponseBody
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_properties ⇒ OpenStruct (readonly)
Returns 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 |
#type ⇒ Samsara::Types::FormsDateTimeValueObjectResponseBodyType (readonly)
Returns The type of datetime format. Valid values: ‘datetime`, `date`, `time`.
12 13 14 |
# File 'lib/samsara_api/types/forms_date_time_value_object_response_body.rb', line 12 def type @type end |
#value ⇒ DateTime (readonly)
Returns 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
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
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_json ⇒ 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 |