Class: NewDemoApiClient::CategoryMetadata

Inherits:
Object
  • Object
show all
Defined in:
lib/test_sdk/types/category_metadata.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, friendly_name:, default_user_type: OMIT, additional_properties: nil) ⇒ NewDemoApiClient::CategoryMetadata

Parameters:

  • name (String)

    The name of the category.

  • friendly_name (String)

    The friendly displayable name of the category.

  • default_user_type (NewDemoApiClient::CategoryMetadataDefaultUserType) (defaults to: OMIT)

    The default user type for the category.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/test_sdk/types/category_metadata.rb', line 28

def initialize(name:, friendly_name:, default_user_type: OMIT, additional_properties: nil)
  @name = name
  @friendly_name = friendly_name
  @default_user_type = default_user_type if default_user_type != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "name": name,
    "friendly_name": friendly_name,
    "default_user_type": default_user_type
  }.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



16
17
18
# File 'lib/test_sdk/types/category_metadata.rb', line 16

def additional_properties
  @additional_properties
end

#default_user_typeNewDemoApiClient::CategoryMetadataDefaultUserType (readonly)

Returns The default user type for the category.

Returns:



14
15
16
# File 'lib/test_sdk/types/category_metadata.rb', line 14

def default_user_type
  @default_user_type
end

#friendly_nameString (readonly)

Returns The friendly displayable name of the category.

Returns:

  • (String)

    The friendly displayable name of the category.



12
13
14
# File 'lib/test_sdk/types/category_metadata.rb', line 12

def friendly_name
  @friendly_name
end

#nameString (readonly)

Returns The name of the category.

Returns:

  • (String)

    The name of the category.



10
11
12
# File 'lib/test_sdk/types/category_metadata.rb', line 10

def name
  @name
end

Class Method Details

.from_json(json_object:) ⇒ NewDemoApiClient::CategoryMetadata

Deserialize a JSON object to an instance of CategoryMetadata

Parameters:

  • json_object (String)

Returns:



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/test_sdk/types/category_metadata.rb', line 46

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  name = parsed_json["name"]
  friendly_name = parsed_json["friendly_name"]
  default_user_type = parsed_json["default_user_type"]
  new(
    name: name,
    friendly_name: friendly_name,
    default_user_type: default_user_type,
    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)


73
74
75
76
77
# File 'lib/test_sdk/types/category_metadata.rb', line 73

def self.validate_raw(obj:)
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.friendly_name.is_a?(String) != false || raise("Passed value for field obj.friendly_name is not the expected type, validation failed.")
  obj.default_user_type&.is_a?(NewDemoApiClient::CategoryMetadataDefaultUserType) != false || raise("Passed value for field obj.default_user_type is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of CategoryMetadata to a JSON object

Returns:

  • (String)


63
64
65
# File 'lib/test_sdk/types/category_metadata.rb', line 63

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