Class: NewDemoApiClient::CategoryMetadata
- Inherits:
-
Object
- Object
- NewDemoApiClient::CategoryMetadata
- Defined in:
- lib/test_sdk/types/category_metadata.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#default_user_type ⇒ NewDemoApiClient::CategoryMetadataDefaultUserType
readonly
The default user type for the category.
-
#friendly_name ⇒ String
readonly
The friendly displayable name of the category.
-
#name ⇒ String
readonly
The name of the category.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ NewDemoApiClient::CategoryMetadata
Deserialize a JSON object to an instance of CategoryMetadata.
-
.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.
Instance Method Summary collapse
- #initialize(name:, friendly_name:, default_user_type: OMIT, additional_properties: nil) ⇒ NewDemoApiClient::CategoryMetadata constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of CategoryMetadata to a JSON object.
Constructor Details
#initialize(name:, friendly_name:, default_user_type: OMIT, additional_properties: nil) ⇒ NewDemoApiClient::CategoryMetadata
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_properties ⇒ OpenStruct (readonly)
Returns 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_type ⇒ NewDemoApiClient::CategoryMetadataDefaultUserType (readonly)
Returns The default user type for the category.
14 15 16 |
# File 'lib/test_sdk/types/category_metadata.rb', line 14 def default_user_type @default_user_type end |
#friendly_name ⇒ String (readonly)
Returns 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 |
#name ⇒ String (readonly)
Returns 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
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.
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
63 64 65 |
# File 'lib/test_sdk/types/category_metadata.rb', line 63 def to_json(*_args) @_field_set&.to_json end |