Class: TrophyApiClient::CreateAttributeRequestItem

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, key:, type:, additional_properties: nil) ⇒ TrophyApiClient::CreateAttributeRequestItem

Parameters:

  • name (String)

    The attribute name.

  • key (String)

    The attribute key. Only alphanumeric characters, hyphens, and underscores are permitted.

  • type (TrophyApiClient::CreateAttributeRequestItemType)

    The attribute type.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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

#keyString (readonly)

Returns The attribute key. Only alphanumeric characters, hyphens, and underscores are permitted.

Returns:

  • (String)

    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

#nameString (readonly)

Returns The attribute name.

Returns:

  • (String)

    The attribute name.



11
12
13
# File 'lib/trophy_api_client/types/create_attribute_request_item.rb', line 11

def name
  @name
end

#typeTrophyApiClient::CreateAttributeRequestItemType (readonly)

Returns The attribute type.

Returns:



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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


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