Class: Gusto::CustomFields::CompanyCustomField

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

Overview

A custom field on a company

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uuid:, name:, type:, description: OMIT, selection_options: OMIT, additional_properties: nil) ⇒ Gusto::CustomFields::CompanyCustomField

Parameters:

  • uuid (String)

    UUID of the company custom field

  • name (String)

    Name of the company custom field

  • type (Gusto::CustomFields::CustomFieldType)
  • description (String) (defaults to: OMIT)

    Description of the company custom field

  • 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



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fern_gusto/custom_fields/types/company_custom_field.rb', line 35

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



21
22
23
# File 'lib/fern_gusto/custom_fields/types/company_custom_field.rb', line 21

def additional_properties
  @additional_properties
end

#descriptionString (readonly)

Returns Description of the company custom field.

Returns:

  • (String)

    Description of the company custom field



17
18
19
# File 'lib/fern_gusto/custom_fields/types/company_custom_field.rb', line 17

def description
  @description
end

#nameString (readonly)

Returns Name of the company custom field.

Returns:

  • (String)

    Name of the company custom field



13
14
15
# File 'lib/fern_gusto/custom_fields/types/company_custom_field.rb', line 13

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.



19
20
21
# File 'lib/fern_gusto/custom_fields/types/company_custom_field.rb', line 19

def selection_options
  @selection_options
end

#typeGusto::CustomFields::CustomFieldType (readonly)



15
16
17
# File 'lib/fern_gusto/custom_fields/types/company_custom_field.rb', line 15

def type
  @type
end

#uuidString (readonly)

Returns UUID of the company custom field.

Returns:

  • (String)

    UUID of the company custom field



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

def uuid
  @uuid
end

Class Method Details

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

Parameters:

  • json_object (String)

Returns:



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/fern_gusto/custom_fields/types/company_custom_field.rb', line 50

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

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


79
80
81
82
83
84
85
# File 'lib/fern_gusto/custom_fields/types/company_custom_field.rb', line 79

def self.validate_raw(obj:)
  obj.uuid.is_a?(String) != false || raise("Passed value for field obj.uuid 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.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)


70
71
72
# File 'lib/fern_gusto/custom_fields/types/company_custom_field.rb', line 70

def to_json
  @_field_set&.to_json
end