Class: Gusto::CustomFields::EmployeeCustomField

Inherits:
Object
  • Object
show all
Defined in:
lib/fern_gusto/custom_fields/types/employee_custom_field.rb

Overview

A custom field of an employee

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, company_custom_field_id:, name:, type:, description: OMIT, value:, selection_options: OMIT, additional_properties: nil) ⇒ Gusto::CustomFields::EmployeeCustomField

Parameters:

  • name (String)
  • type (Gusto::CustomFields::CustomFieldType)
  • description (String) (defaults to: OMIT)
  • value (String)
  • selection_options (Array<String>) (defaults to: OMIT)

    An array of options for fields of type radio. Otherwise, null.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fern_gusto/custom_fields/types/employee_custom_field.rb', line 43

def initialize(id:, company_custom_field_id:, name:, type:, description: OMIT, value:, selection_options: OMIT, additional_properties: nil)
  @id = id
  @company_custom_field_id = company_custom_field_id
  @name = name
  @type = type
  @description = description if description != OMIT
  @value = value
  @selection_options = selection_options if selection_options != OMIT
  @additional_properties = additional_properties
  @_field_set = { "id": id, "company_custom_field_id": company_custom_field_id, "name": name, "type": type, "description": description, "value": value, "selection_options": selection_options }.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



26
27
28
# File 'lib/fern_gusto/custom_fields/types/employee_custom_field.rb', line 26

def additional_properties
  @additional_properties
end

#company_custom_field_idObject (readonly)

fields



14
15
16
# File 'lib/fern_gusto/custom_fields/types/employee_custom_field.rb', line 14

def company_custom_field_id
  @company_custom_field_id
end

#descriptionString (readonly)

Returns:

  • (String)


20
21
22
# File 'lib/fern_gusto/custom_fields/types/employee_custom_field.rb', line 20

def description
  @description
end

#idString (readonly)

Returns:

  • (String)


11
12
13
# File 'lib/fern_gusto/custom_fields/types/employee_custom_field.rb', line 11

def id
  @id
end

#nameString (readonly)

Returns:

  • (String)


16
17
18
# File 'lib/fern_gusto/custom_fields/types/employee_custom_field.rb', line 16

def name
  @name
end

#selection_optionsArray<String> (readonly)

Returns An array of options for fields of type radio. Otherwise, null.

Returns:

  • (Array<String>)

    An array of options for fields of type radio. Otherwise, null.



24
25
26
# File 'lib/fern_gusto/custom_fields/types/employee_custom_field.rb', line 24

def selection_options
  @selection_options
end

#typeGusto::CustomFields::CustomFieldType (readonly)



18
19
20
# File 'lib/fern_gusto/custom_fields/types/employee_custom_field.rb', line 18

def type
  @type
end

#valueString (readonly)

Returns:

  • (String)


22
23
24
# File 'lib/fern_gusto/custom_fields/types/employee_custom_field.rb', line 22

def value
  @value
end

Class Method Details

.from_json(json_object:) ⇒ Gusto::CustomFields::EmployeeCustomField

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
# File 'lib/fern_gusto/custom_fields/types/employee_custom_field.rb', line 60

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = parsed_json["id"]
  company_custom_field_id = parsed_json["company_custom_field_id"]
  name = parsed_json["name"]
  type = parsed_json["type"]
  description = parsed_json["description"]
  value = parsed_json["value"]
  selection_options = parsed_json["selection_options"]
  new(
    id: id,
    company_custom_field_id: company_custom_field_id,
    name: name,
    type: type,
    description: description,
    value: value,
    selection_options: selection_options,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


93
94
95
96
97
98
99
100
101
# File 'lib/fern_gusto/custom_fields/types/employee_custom_field.rb', line 93

def self.validate_raw(obj:)
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.company_custom_field_id.is_a?(String) != false || raise("Passed value for field obj.company_custom_field_id is not the expected type, validation failed.")
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.type.is_a?(Gusto::CustomFields::CustomFieldType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
  obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
  obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
  obj.selection_options&.is_a?(Array) != false || raise("Passed value for field obj.selection_options is not the expected type, validation failed.")
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


84
85
86
# File 'lib/fern_gusto/custom_fields/types/employee_custom_field.rb', line 84

def to_json
  @_field_set&.to_json
end