Class: TrophyApiClient::AdminPointsLevel
- Inherits:
-
Object
- Object
- TrophyApiClient::AdminPointsLevel
- 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
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#badge ⇒ TrophyApiClient::AdminPointsLevelBadge
readonly
The badge for the level, or null if no badge is set.
-
#description ⇒ String
readonly
The level description.
-
#id ⇒ String
readonly
The UUID of the level.
-
#key ⇒ String
readonly
The level key.
-
#name ⇒ String
readonly
The name of the level.
-
#points ⇒ Integer
readonly
The threshold points value for the level.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::AdminPointsLevel
Deserialize a JSON object to an instance of AdminPointsLevel.
-
.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(id:, name:, key:, points:, description:, badge: OMIT, additional_properties: nil) ⇒ TrophyApiClient::AdminPointsLevel constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of AdminPointsLevel to a JSON object.
Constructor Details
#initialize(id:, name:, key:, points:, description:, badge: OMIT, additional_properties: nil) ⇒ TrophyApiClient::AdminPointsLevel
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_properties ⇒ OpenStruct (readonly)
Returns 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 |
#badge ⇒ TrophyApiClient::AdminPointsLevelBadge (readonly)
Returns The badge for the level, or null if no badge is set.
21 22 23 |
# File 'lib/trophy_api_client/types/admin_points_level.rb', line 21 def badge @badge end |
#description ⇒ String (readonly)
Returns The level description.
19 20 21 |
# File 'lib/trophy_api_client/types/admin_points_level.rb', line 19 def description @description end |
#id ⇒ String (readonly)
Returns The UUID of the level.
11 12 13 |
# File 'lib/trophy_api_client/types/admin_points_level.rb', line 11 def id @id end |
#key ⇒ String (readonly)
Returns The level key.
15 16 17 |
# File 'lib/trophy_api_client/types/admin_points_level.rb', line 15 def key @key end |
#name ⇒ String (readonly)
Returns The name of the level.
13 14 15 |
# File 'lib/trophy_api_client/types/admin_points_level.rb', line 13 def name @name end |
#points ⇒ Integer (readonly)
Returns 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
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.
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
90 91 92 |
# File 'lib/trophy_api_client/types/admin_points_level.rb', line 90 def to_json(*_args) @_field_set&.to_json end |