Class: TrophyApiClient::AdminPointsLevel

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

Overview

A points level as returned from admin 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:, points:, description:, badge: OMIT, additional_properties: nil) ⇒ TrophyApiClient::AdminPointsLevel

Parameters:

  • id (String)

    The UUID of the level.

  • name (String)

    The name of the level.

  • key (String)

    The level key.

  • points (Integer)

    The threshold points value for the level.

  • description (String)

    The level description.

  • badge (TrophyApiClient::AdminPointsLevelBadge) (defaults to: OMIT)

    The badge for the level, or null if no badge is set.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/trophy_api_client/types/admin_points_level.rb', line 38

def initialize(id:, name:, key:, points:, description:, badge: OMIT, additional_properties: nil)
  @id = id
  @name = name
  @key = key
  @points = points
  @description = description
  @badge = badge if badge != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "id": id,
    "name": name,
    "key": key,
    "points": points,
    "description": description,
    "badge": badge
  }.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



23
24
25
# File 'lib/trophy_api_client/types/admin_points_level.rb', line 23

def additional_properties
  @additional_properties
end

#badgeTrophyApiClient::AdminPointsLevelBadge (readonly)

Returns The badge for the level, or null if no badge is set.

Returns:



21
22
23
# File 'lib/trophy_api_client/types/admin_points_level.rb', line 21

def badge
  @badge
end

#descriptionString (readonly)

Returns The level description.

Returns:

  • (String)

    The level description.



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

def description
  @description
end

#idString (readonly)

Returns The UUID of the level.

Returns:

  • (String)

    The UUID of the level.



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

def id
  @id
end

#keyString (readonly)

Returns The level key.

Returns:

  • (String)

    The level key.



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

def key
  @key
end

#nameString (readonly)

Returns The name of the level.

Returns:

  • (String)

    The name of the level.



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

def name
  @name
end

#pointsInteger (readonly)

Returns The threshold points value for the level.

Returns:

  • (Integer)

    The threshold points value for the level.



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

def points
  @points
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::AdminPointsLevel

Deserialize a JSON object to an instance of AdminPointsLevel

Parameters:

  • json_object (String)

Returns:



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/trophy_api_client/types/admin_points_level.rb', line 62

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"]
  points = parsed_json["points"]
  description = parsed_json["description"]
  if parsed_json["badge"].nil?
    badge = nil
  else
    badge = parsed_json["badge"].to_json
    badge = TrophyApiClient::AdminPointsLevelBadge.from_json(json_object: badge)
  end
  new(
    id: id,
    name: name,
    key: key,
    points: points,
    description: description,
    badge: badge,
    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)


100
101
102
103
104
105
106
107
# File 'lib/trophy_api_client/types/admin_points_level.rb', line 100

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.points.is_a?(Integer) != false || raise("Passed value for field obj.points is not the expected type, validation failed.")
  obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
  obj.badge.nil? || TrophyApiClient::AdminPointsLevelBadge.validate_raw(obj: obj.badge)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of AdminPointsLevel to a JSON object

Returns:

  • (String)


90
91
92
# File 'lib/trophy_api_client/types/admin_points_level.rb', line 90

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