Class: TrophyApiClient::AdminAttribute

Inherits:
Object
  • Object
show all
Defined in:
lib/trophy_api_client/types/admin_attribute.rb

Overview

An attribute returned from the admin attributes endpoints.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Parameters:

  • id (String)

    The UUID of the attribute.

  • name (String)

    The attribute name.

  • key (String)

    The attribute key.

  • type (TrophyApiClient::AdminAttributeType)

    The attribute type.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



32
33
34
35
36
37
38
39
# File 'lib/trophy_api_client/types/admin_attribute.rb', line 32

def initialize(id:, name:, key:, type:, additional_properties: nil)
  @id = id
  @name = name
  @key = key
  @type = type
  @additional_properties = additional_properties
  @_field_set = { "id": id, "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



19
20
21
# File 'lib/trophy_api_client/types/admin_attribute.rb', line 19

def additional_properties
  @additional_properties
end

#idString (readonly)

Returns The UUID of the attribute.

Returns:

  • (String)

    The UUID of the attribute.



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

def id
  @id
end

#keyString (readonly)

Returns The attribute key.

Returns:

  • (String)

    The attribute key.



15
16
17
# File 'lib/trophy_api_client/types/admin_attribute.rb', line 15

def key
  @key
end

#nameString (readonly)

Returns The attribute name.

Returns:

  • (String)

    The attribute name.



13
14
15
# File 'lib/trophy_api_client/types/admin_attribute.rb', line 13

def name
  @name
end

#typeTrophyApiClient::AdminAttributeType (readonly)

Returns The attribute type.

Returns:



17
18
19
# File 'lib/trophy_api_client/types/admin_attribute.rb', line 17

def type
  @type
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::AdminAttribute

Deserialize a JSON object to an instance of AdminAttribute

Parameters:

  • json_object (String)

Returns:



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/trophy_api_client/types/admin_attribute.rb', line 45

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


74
75
76
77
78
79
# File 'lib/trophy_api_client/types/admin_attribute.rb', line 74

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.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::AdminAttributeType) != 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 AdminAttribute to a JSON object

Returns:

  • (String)


64
65
66
# File 'lib/trophy_api_client/types/admin_attribute.rb', line 64

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