Class: TrophyApiClient::PointsLevel
- Inherits:
-
Object
- Object
- TrophyApiClient::PointsLevel
- Defined in:
- lib/trophy_api_client/types/points_level.rb
Overview
A level within a points system.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#badge_url ⇒ String
readonly
The URL of the badge image for the level.
-
#description ⇒ String
readonly
The description of the level.
-
#id ⇒ String
readonly
The ID of the level.
-
#key ⇒ String
readonly
The unique key of the level.
-
#name ⇒ String
readonly
The name of the level.
-
#points ⇒ Integer
readonly
The points threshold required to reach this level.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::PointsLevel
Deserialize a JSON object to an instance of PointsLevel.
-
.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:, key:, name:, description:, points:, badge_url: OMIT, additional_properties: nil) ⇒ TrophyApiClient::PointsLevel constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of PointsLevel to a JSON object.
Constructor Details
#initialize(id:, key:, name:, description:, points:, badge_url: OMIT, additional_properties: nil) ⇒ TrophyApiClient::PointsLevel
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/trophy_api_client/types/points_level.rb', line 37 def initialize(id:, key:, name:, description:, points:, badge_url: OMIT, additional_properties: nil) @id = id @key = key @name = name @description = description @badge_url = badge_url if badge_url != OMIT @points = points @additional_properties = additional_properties @_field_set = { "id": id, "key": key, "name": name, "description": description, "badgeUrl": badge_url, "points": points }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
22 23 24 |
# File 'lib/trophy_api_client/types/points_level.rb', line 22 def additional_properties @additional_properties end |
#badge_url ⇒ String (readonly)
Returns The URL of the badge image for the level.
18 19 20 |
# File 'lib/trophy_api_client/types/points_level.rb', line 18 def badge_url @badge_url end |
#description ⇒ String (readonly)
Returns The description of the level.
16 17 18 |
# File 'lib/trophy_api_client/types/points_level.rb', line 16 def description @description end |
#id ⇒ String (readonly)
Returns The ID of the level.
10 11 12 |
# File 'lib/trophy_api_client/types/points_level.rb', line 10 def id @id end |
#key ⇒ String (readonly)
Returns The unique key of the level.
12 13 14 |
# File 'lib/trophy_api_client/types/points_level.rb', line 12 def key @key end |
#name ⇒ String (readonly)
Returns The name of the level.
14 15 16 |
# File 'lib/trophy_api_client/types/points_level.rb', line 14 def name @name end |
#points ⇒ Integer (readonly)
Returns The points threshold required to reach this level.
20 21 22 |
# File 'lib/trophy_api_client/types/points_level.rb', line 20 def points @points end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::PointsLevel
Deserialize a JSON object to an instance of PointsLevel
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/trophy_api_client/types/points_level.rb', line 61 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = parsed_json["id"] key = parsed_json["key"] name = parsed_json["name"] description = parsed_json["description"] badge_url = parsed_json["badgeUrl"] points = parsed_json["points"] new( id: id, key: key, name: name, description: description, badge_url: badge_url, points: points, 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.
94 95 96 97 98 99 100 101 |
# File 'lib/trophy_api_client/types/points_level.rb', line 94 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.key.is_a?(String) != false || raise("Passed value for field obj.key 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.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url 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.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of PointsLevel to a JSON object
84 85 86 |
# File 'lib/trophy_api_client/types/points_level.rb', line 84 def to_json(*_args) @_field_set&.to_json end |