Class: Samsara::Types::FormsFieldDefinitionObjectResponseBody

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

Overview

Forms field definition object.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(allow_manual_entry: OMIT, allowed_asset_types: OMIT, allowed_date_time_value_type: OMIT, autofill_from_id: OMIT, columns: OMIT, conditional_actions: OMIT, filter_by_role_ids: OMIT, id:, include_drivers: OMIT, include_users: OMIT, is_autofill_source: OMIT, is_required:, label:, num_decimal_places: OMIT, options: OMIT, question_weight: OMIT, type:, additional_properties: nil) ⇒ Samsara::Types::FormsFieldDefinitionObjectResponseBody

Parameters:

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

    Additional properties unmapped to the current class definition



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/samsara_api/types/forms_field_definition_object_response_body.rb', line 106

def initialize(allow_manual_entry: OMIT, allowed_asset_types: OMIT, allowed_date_time_value_type: OMIT, autofill_from_id: OMIT, columns: OMIT, conditional_actions: OMIT, filter_by_role_ids: OMIT, id:, include_drivers: OMIT, include_users: OMIT, is_autofill_source: OMIT, is_required:, label:, num_decimal_places: OMIT, options: OMIT, question_weight: OMIT, type:, additional_properties: nil)
  @allow_manual_entry = allow_manual_entry if allow_manual_entry != OMIT
  @allowed_asset_types = allowed_asset_types if allowed_asset_types != OMIT
  @allowed_date_time_value_type = allowed_date_time_value_type if allowed_date_time_value_type != OMIT
  @autofill_from_id = autofill_from_id if autofill_from_id != OMIT
  @columns = columns if columns != OMIT
  @conditional_actions = conditional_actions if conditional_actions != OMIT
  @filter_by_role_ids = filter_by_role_ids if filter_by_role_ids != OMIT
  @id = id
  @include_drivers = include_drivers if include_drivers != OMIT
  @include_users = include_users if include_users != OMIT
  @is_autofill_source = is_autofill_source if is_autofill_source != OMIT
  @is_required = is_required
  @label = label
  @num_decimal_places = num_decimal_places if num_decimal_places != OMIT
  @options = options if options != OMIT
  @question_weight = question_weight if question_weight != OMIT
  @type = type
  @additional_properties = additional_properties
  @_field_set = { "allowManualEntry": allow_manual_entry, "allowedAssetTypes": allowed_asset_types, "allowedDateTimeValueType": allowed_date_time_value_type, "autofillFromId": autofill_from_id, "columns": columns, "conditionalActions": conditional_actions, "filterByRoleIds": filter_by_role_ids, "id": id, "includeDrivers": include_drivers, "includeUsers": include_users, "isAutofillSource": is_autofill_source, "isRequired": is_required, "label": label, "numDecimalPlaces": num_decimal_places, "options": options, "questionWeight": question_weight, "type": type }.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



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

def additional_properties
  @additional_properties
end

#allow_manual_entry ⇒ Object (readonly)

person fields.



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

def allow_manual_entry
  @allow_manual_entry
end

#allowed_asset_types ⇒ Object (readonly)

for asset fields.



20
21
22
# File 'lib/samsara_api/types/forms_field_definition_object_response_body.rb', line 20

def allowed_asset_types
  @allowed_asset_types
end

#allowed_date_time_value_type ⇒ Object (readonly)

fields. Valid values: datetime, date, time



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

def allowed_date_time_value_type
  @allowed_date_time_value_type
end

#autofill_from_id ⇒ Object (readonly)

field.



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

def autofill_from_id
  @autofill_from_id
end

#columns ⇒ Array<Samsara::Types::FormsTableFieldDefinitionObjectResponseBody> (readonly)

Returns List of columns in the table field.

Returns:



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

def columns
  @columns
end

#conditional_actions ⇒ Array<Samsara::Types::FormsConditionalActionObjectResponseBody> (readonly)

Returns List of conditional actions.

Returns:



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

def conditional_actions
  @conditional_actions
end

#filter_by_role_ids ⇒ Object (readonly)

people for this field. Only present for person fields.



34
35
36
# File 'lib/samsara_api/types/forms_field_definition_object_response_body.rb', line 34

def filter_by_role_ids
  @filter_by_role_ids
end

#id ⇒ String (readonly)

Returns Identifier of the field.

Returns:

  • (String) —

    Identifier of the field.



36
37
38
# File 'lib/samsara_api/types/forms_field_definition_object_response_body.rb', line 36

def id
  @id
end

#include_drivers ⇒ Object (readonly)

for person fields.



39
40
41
# File 'lib/samsara_api/types/forms_field_definition_object_response_body.rb', line 39

def include_drivers
  @include_drivers
end

#include_users ⇒ Object (readonly)

for person fields.



42
43
44
# File 'lib/samsara_api/types/forms_field_definition_object_response_body.rb', line 42

def include_users
  @include_users
end

#is_autofill_source ⇒ Object (readonly)

present for media fields that have autofill enabled.



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

def is_autofill_source
  @is_autofill_source
end

#is_required ⇒ Boolean (readonly)

Returns Indicates whether the form field is required to be filled out by the user.

Returns:

  • (Boolean) —

    Indicates whether the form field is required to be filled out by the user.



47
48
49
# File 'lib/samsara_api/types/forms_field_definition_object_response_body.rb', line 47

def is_required
  @is_required
end

#label ⇒ String (readonly)

Returns Label of the field.

Returns:

  • (String) —

    Label of the field.



49
50
51
# File 'lib/samsara_api/types/forms_field_definition_object_response_body.rb', line 49

def label
  @label
end

#num_decimal_places ⇒ Long (readonly)

Returns Number of decimal places allowed. Only present for number fields.

Returns:

  • (Long) —

    Number of decimal places allowed. Only present for number fields.



51
52
53
# File 'lib/samsara_api/types/forms_field_definition_object_response_body.rb', line 51

def num_decimal_places
  @num_decimal_places
end

#options ⇒ Array<Samsara::Types::FormsSelectOptionObjectResponseBody> (readonly)

Returns List of select options for check boxes or multiple choice fields.

Returns:



53
54
55
# File 'lib/samsara_api/types/forms_field_definition_object_response_body.rb', line 53

def options
  @options
end

#question_weight ⇒ Object (readonly)

scoring.



59
60
61
# File 'lib/samsara_api/types/forms_field_definition_object_response_body.rb', line 59

def question_weight
  @question_weight
end

#type ⇒ Object (readonly)

instruction, media_instruction, table



63
64
65
# File 'lib/samsara_api/types/forms_field_definition_object_response_body.rb', line 63

def type
  @type
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/samsara_api/types/forms_field_definition_object_response_body.rb', line 134

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  allow_manual_entry = parsed_json["allowManualEntry"]
  allowed_asset_types = parsed_json["allowedAssetTypes"]
  allowed_date_time_value_type = parsed_json["allowedDateTimeValueType"]
  autofill_from_id = parsed_json["autofillFromId"]
  columns = parsed_json["columns"]&.map do | item |
  item = item.to_json
  Samsara::Types::FormsTableFieldDefinitionObjectResponseBody.from_json(json_object: item)
end
  conditional_actions = parsed_json["conditionalActions"]&.map do | item |
  item = item.to_json
  Samsara::Types::FormsConditionalActionObjectResponseBody.from_json(json_object: item)
end
  filter_by_role_ids = parsed_json["filterByRoleIds"]
  id = parsed_json["id"]
  include_drivers = parsed_json["includeDrivers"]
  include_users = parsed_json["includeUsers"]
  is_autofill_source = parsed_json["isAutofillSource"]
  is_required = parsed_json["isRequired"]
  label = parsed_json["label"]
  num_decimal_places = parsed_json["numDecimalPlaces"]
  options = parsed_json["options"]&.map do | item |
  item = item.to_json
  Samsara::Types::FormsSelectOptionObjectResponseBody.from_json(json_object: item)
end
  question_weight = parsed_json["questionWeight"]
  type = parsed_json["type"]
  new(
    allow_manual_entry: allow_manual_entry,
    allowed_asset_types: allowed_asset_types,
    allowed_date_time_value_type: allowed_date_time_value_type,
    autofill_from_id: autofill_from_id,
    columns: columns,
    conditional_actions: conditional_actions,
    filter_by_role_ids: filter_by_role_ids,
    id: id,
    include_drivers: include_drivers,
    include_users: include_users,
    is_autofill_source: is_autofill_source,
    is_required: is_required,
    label: label,
    num_decimal_places: num_decimal_places,
    options: options,
    question_weight: question_weight,
    type: type,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/samsara_api/types/forms_field_definition_object_response_body.rb', line 196

def self.validate_raw(obj:)
  obj.allow_manual_entry&.is_a?(Boolean) != false || raise("Passed value for field obj.allow_manual_entry is not the expected type, validation failed.")
  obj.allowed_asset_types&.is_a?(Array) != false || raise("Passed value for field obj.allowed_asset_types is not the expected type, validation failed.")
  obj.allowed_date_time_value_type&.is_a?(Samsara::Types::FormsFieldDefinitionObjectResponseBodyAllowedDateTimeValueType) != false || raise("Passed value for field obj.allowed_date_time_value_type is not the expected type, validation failed.")
  obj.autofill_from_id&.is_a?(String) != false || raise("Passed value for field obj.autofill_from_id is not the expected type, validation failed.")
  obj.columns&.is_a?(Array) != false || raise("Passed value for field obj.columns is not the expected type, validation failed.")
  obj.conditional_actions&.is_a?(Array) != false || raise("Passed value for field obj.conditional_actions is not the expected type, validation failed.")
  obj.filter_by_role_ids&.is_a?(Array) != false || raise("Passed value for field obj.filter_by_role_ids is not the expected type, validation failed.")
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.include_drivers&.is_a?(Boolean) != false || raise("Passed value for field obj.include_drivers is not the expected type, validation failed.")
  obj.include_users&.is_a?(Boolean) != false || raise("Passed value for field obj.include_users is not the expected type, validation failed.")
  obj.is_autofill_source&.is_a?(Boolean) != false || raise("Passed value for field obj.is_autofill_source is not the expected type, validation failed.")
  obj.is_required.is_a?(Boolean) != false || raise("Passed value for field obj.is_required 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.num_decimal_places&.is_a?(Long) != false || raise("Passed value for field obj.num_decimal_places is not the expected type, validation failed.")
  obj.options&.is_a?(Array) != false || raise("Passed value for field obj.options is not the expected type, validation failed.")
  obj.question_weight&.is_a?(Long) != false || raise("Passed value for field obj.question_weight is not the expected type, validation failed.")
  obj.type.is_a?(Samsara::Types::FormsFieldDefinitionObjectResponseBodyType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
end

Instance Method Details

#to_json ⇒ String

Returns:

  • (String)


187
188
189
# File 'lib/samsara_api/types/forms_field_definition_object_response_body.rb', line 187

def to_json
  @_field_set&.to_json
end