Class: Samsara::Types::FieldTypesObjectResponseBody

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field_type:, label:, multiple_choice_field_type_meta_data: OMIT, number_field_type_meta_data: OMIT, required_field:, signature_field_type_meta_data: OMIT, additional_properties: nil) ⇒ Samsara::Types::FieldTypesObjectResponseBody

Parameters:



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/samsara_api/types/field_types_object_response_body.rb', line 44

def initialize(field_type:, label:, multiple_choice_field_type_meta_data: OMIT, number_field_type_meta_data: OMIT, required_field:, signature_field_type_meta_data: OMIT, additional_properties: nil)
  @field_type = field_type
  @label = label
  @multiple_choice_field_type_meta_data =  if  != OMIT
  @number_field_type_meta_data =  if  != OMIT
  @required_field = required_field
  @signature_field_type_meta_data =  if  != OMIT
  @additional_properties = additional_properties
  @_field_set = { "fieldType": field_type, "label": label, "multipleChoiceFieldTypeMetaData": , "numberFieldTypeMetaData": , "requiredField": required_field, "signatureFieldTypeMetaData":  }.reject do | _k, v |
  v == OMIT
end
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



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

def additional_properties
  @additional_properties
end

#field_typeObject (readonly)

‘barcode`



15
16
17
# File 'lib/samsara_api/types/field_types_object_response_body.rb', line 15

def field_type
  @field_type
end

#labelString (readonly)

Returns The name of the field type.

Returns:

  • (String)

    The name of the field type.



17
18
19
# File 'lib/samsara_api/types/field_types_object_response_body.rb', line 17

def label
  @label
end

#multiple_choice_field_type_meta_dataArray<Samsara::Types::MultipleChoiceFieldTypeMetaDataObjectResponseBody> (readonly)

Returns A list of the multiple choice field option labels.

Returns:



19
20
21
# File 'lib/samsara_api/types/field_types_object_response_body.rb', line 19

def 
  @multiple_choice_field_type_meta_data
end

#number_field_type_meta_dataSamsara::Types::NumberFieldTypeMetaDataObjectResponseBody (readonly)



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

def 
  @number_field_type_meta_data
end

#required_fieldBoolean (readonly)

Returns The indicator that states if the field is required.

Returns:

  • (Boolean)

    The indicator that states if the field is required.



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

def required_field
  @required_field
end

#signature_field_type_meta_dataSamsara::Types::SignatureFieldTypeMetaDataObjectResponseBody (readonly)



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

def 
  @signature_field_type_meta_data
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/samsara_api/types/field_types_object_response_body.rb', line 60

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  field_type = parsed_json["fieldType"]
  label = parsed_json["label"]
   = parsed_json["multipleChoiceFieldTypeMetaData"]&.map do | item |
  item = item.to_json
  Samsara::Types::MultipleChoiceFieldTypeMetaDataObjectResponseBody.from_json(json_object: item)
end
  unless parsed_json["numberFieldTypeMetaData"].nil?
     = parsed_json["numberFieldTypeMetaData"].to_json
     = Samsara::Types::NumberFieldTypeMetaDataObjectResponseBody.from_json(json_object: )
  else
     = nil
  end
  required_field = parsed_json["requiredField"]
  unless parsed_json["signatureFieldTypeMetaData"].nil?
     = parsed_json["signatureFieldTypeMetaData"].to_json
     = Samsara::Types::SignatureFieldTypeMetaDataObjectResponseBody.from_json(json_object: )
  else
     = nil
  end
  new(
    field_type: field_type,
    label: label,
    multiple_choice_field_type_meta_data: ,
    number_field_type_meta_data: ,
    required_field: required_field,
    signature_field_type_meta_data: ,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


104
105
106
107
108
109
110
111
# File 'lib/samsara_api/types/field_types_object_response_body.rb', line 104

def self.validate_raw(obj:)
  obj.field_type.is_a?(Samsara::Types::FieldTypesObjectResponseBodyFieldType) != false || raise("Passed value for field obj.field_type is not the expected type, validation failed.")
  obj.label.is_a?(String) != false || raise("Passed value for field obj.label is not the expected type, validation failed.")
  obj.&.is_a?(Array) != false || raise("Passed value for field obj.multiple_choice_field_type_meta_data is not the expected type, validation failed.")
  obj..nil? || Samsara::Types::NumberFieldTypeMetaDataObjectResponseBody.validate_raw(obj: obj.)
  obj.required_field.is_a?(Boolean) != false || raise("Passed value for field obj.required_field is not the expected type, validation failed.")
  obj..nil? || Samsara::Types::SignatureFieldTypeMetaDataObjectResponseBody.validate_raw(obj: obj.)
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


95
96
97
# File 'lib/samsara_api/types/field_types_object_response_body.rb', line 95

def to_json
  @_field_set&.to_json
end