Class: Merge::Filestorage::AdvancedMetadata

Inherits:
Object
  • Object
show all
Defined in:
lib/merge_ruby_client/filestorage/types/advanced_metadata.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, display_name: OMIT, description: OMIT, is_required: OMIT, is_custom: OMIT, field_choices: OMIT, additional_properties: nil) ⇒ Merge::Filestorage::AdvancedMetadata

Parameters:

  • id (String)
  • display_name (String) (defaults to: OMIT)
  • description (String) (defaults to: OMIT)
  • is_required (Boolean) (defaults to: OMIT)
  • is_custom (Boolean) (defaults to: OMIT)
  • field_choices (Array<Object>) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/merge_ruby_client/filestorage/types/advanced_metadata.rb', line 37

def initialize(id:, display_name: OMIT, description: OMIT, is_required: OMIT, is_custom: OMIT,
               field_choices: OMIT, additional_properties: nil)
  @id = id
  @display_name = display_name if display_name != OMIT
  @description = description if description != OMIT
  @is_required = is_required if is_required != OMIT
  @is_custom = is_custom if is_custom != OMIT
  @field_choices = field_choices if field_choices != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "id": id,
    "display_name": display_name,
    "description": description,
    "is_required": is_required,
    "is_custom": is_custom,
    "field_choices": field_choices
  }.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



22
23
24
# File 'lib/merge_ruby_client/filestorage/types/advanced_metadata.rb', line 22

def additional_properties
  @additional_properties
end

#descriptionString (readonly)

Returns:

  • (String)


14
15
16
# File 'lib/merge_ruby_client/filestorage/types/advanced_metadata.rb', line 14

def description
  @description
end

#display_nameString (readonly)

Returns:

  • (String)


12
13
14
# File 'lib/merge_ruby_client/filestorage/types/advanced_metadata.rb', line 12

def display_name
  @display_name
end

#field_choicesArray<Object> (readonly)

Returns:

  • (Array<Object>)


20
21
22
# File 'lib/merge_ruby_client/filestorage/types/advanced_metadata.rb', line 20

def field_choices
  @field_choices
end

#idString (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/merge_ruby_client/filestorage/types/advanced_metadata.rb', line 10

def id
  @id
end

#is_customBoolean (readonly)

Returns:

  • (Boolean)


18
19
20
# File 'lib/merge_ruby_client/filestorage/types/advanced_metadata.rb', line 18

def is_custom
  @is_custom
end

#is_requiredBoolean (readonly)

Returns:

  • (Boolean)


16
17
18
# File 'lib/merge_ruby_client/filestorage/types/advanced_metadata.rb', line 16

def is_required
  @is_required
end

Class Method Details

.from_json(json_object:) ⇒ Merge::Filestorage::AdvancedMetadata

Deserialize a JSON object to an instance of AdvancedMetadata

Parameters:

  • json_object (String)

Returns:



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/merge_ruby_client/filestorage/types/advanced_metadata.rb', line 62

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = parsed_json["id"]
  display_name = parsed_json["display_name"]
  description = parsed_json["description"]
  is_required = parsed_json["is_required"]
  is_custom = parsed_json["is_custom"]
  field_choices = parsed_json["field_choices"]
  new(
    id: id,
    display_name: display_name,
    description: description,
    is_required: is_required,
    is_custom: is_custom,
    field_choices: field_choices,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


95
96
97
98
99
100
101
102
# File 'lib/merge_ruby_client/filestorage/types/advanced_metadata.rb', line 95

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.display_name&.is_a?(String) != false || raise("Passed value for field obj.display_name 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.is_required&.is_a?(Boolean) != false || raise("Passed value for field obj.is_required is not the expected type, validation failed.")
  obj.is_custom&.is_a?(Boolean) != false || raise("Passed value for field obj.is_custom is not the expected type, validation failed.")
  obj.field_choices&.is_a?(Array) != false || raise("Passed value for field obj.field_choices is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of AdvancedMetadata to a JSON object

Returns:

  • (String)


85
86
87
# File 'lib/merge_ruby_client/filestorage/types/advanced_metadata.rb', line 85

def to_json(*_args)
  @_field_set&.to_json
end