Class: TrophyApiClient::CreateAttributeRequestItem
- Inherits:
-
Object
- Object
- TrophyApiClient::CreateAttributeRequestItem
- Defined in:
- lib/trophy_api_client/types/create_attribute_request_item.rb
Overview
An attribute to create.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#key ⇒ String
readonly
The attribute key.
-
#name ⇒ String
readonly
The attribute name.
-
#type ⇒ TrophyApiClient::CreateAttributeRequestItemType
readonly
The attribute type.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::CreateAttributeRequestItem
Deserialize a JSON object to an instance of CreateAttributeRequestItem.
-
.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:, key:, type:, additional_properties: nil) ⇒ TrophyApiClient::CreateAttributeRequestItem constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of CreateAttributeRequestItem to a JSON object.
Constructor Details
#initialize(name:, key:, type:, additional_properties: nil) ⇒ TrophyApiClient::CreateAttributeRequestItem
31 32 33 34 35 36 37 |
# File 'lib/trophy_api_client/types/create_attribute_request_item.rb', line 31 def initialize(name:, key:, type:, additional_properties: nil) @name = name @key = key @type = type @additional_properties = additional_properties @_field_set = { "name": name, "key": key, "type": type } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
18 19 20 |
# File 'lib/trophy_api_client/types/create_attribute_request_item.rb', line 18 def additional_properties @additional_properties end |
#key ⇒ String (readonly)
Returns The attribute key. Only alphanumeric characters, hyphens, and underscores are permitted.
14 15 16 |
# File 'lib/trophy_api_client/types/create_attribute_request_item.rb', line 14 def key @key end |
#name ⇒ String (readonly)
Returns The attribute name.
11 12 13 |
# File 'lib/trophy_api_client/types/create_attribute_request_item.rb', line 11 def name @name end |
#type ⇒ TrophyApiClient::CreateAttributeRequestItemType (readonly)
Returns The attribute type.
16 17 18 |
# File 'lib/trophy_api_client/types/create_attribute_request_item.rb', line 16 def type @type end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::CreateAttributeRequestItem
Deserialize a JSON object to an instance of CreateAttributeRequestItem
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/trophy_api_client/types/create_attribute_request_item.rb', line 43 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) name = parsed_json["name"] key = parsed_json["key"] type = parsed_json["type"] new( name: name, key: key, type: 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.
70 71 72 73 74 |
# File 'lib/trophy_api_client/types/create_attribute_request_item.rb', line 70 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.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.") obj.type.is_a?(TrophyApiClient::CreateAttributeRequestItemType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of CreateAttributeRequestItem to a JSON object
60 61 62 |
# File 'lib/trophy_api_client/types/create_attribute_request_item.rb', line 60 def to_json(*_args) @_field_set&.to_json end |