Class: TrophyApiClient::LeaderboardRanking
- Inherits:
-
Object
- Object
- TrophyApiClient::LeaderboardRanking
- Defined in:
- lib/trophy_api_client/types/leaderboard_ranking.rb
Overview
A user’s ranking in a leaderboard.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#rank ⇒ Integer
readonly
The user’s rank in the leaderboard.
-
#user_id ⇒ String
readonly
The ID of the user.
-
#user_name ⇒ String
readonly
The name of the user.
-
#value ⇒ Integer
readonly
The user’s value for this leaderboard (points, metric value, etc.).
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::LeaderboardRanking
Deserialize a JSON object to an instance of LeaderboardRanking.
-
.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(user_id:, rank:, value:, user_name: OMIT, additional_properties: nil) ⇒ TrophyApiClient::LeaderboardRanking constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of LeaderboardRanking to a JSON object.
Constructor Details
#initialize(user_id:, rank:, value:, user_name: OMIT, additional_properties: nil) ⇒ TrophyApiClient::LeaderboardRanking
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/trophy_api_client/types/leaderboard_ranking.rb', line 31 def initialize(user_id:, rank:, value:, user_name: OMIT, additional_properties: nil) @user_id = user_id @user_name = user_name if user_name != OMIT @rank = rank @value = value @additional_properties = additional_properties @_field_set = { "userId": user_id, "userName": user_name, "rank": rank, "value": value }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
18 19 20 |
# File 'lib/trophy_api_client/types/leaderboard_ranking.rb', line 18 def additional_properties @additional_properties end |
#rank ⇒ Integer (readonly)
14 15 16 |
# File 'lib/trophy_api_client/types/leaderboard_ranking.rb', line 14 def rank @rank end |
#user_id ⇒ String (readonly)
10 11 12 |
# File 'lib/trophy_api_client/types/leaderboard_ranking.rb', line 10 def user_id @user_id end |
#user_name ⇒ String (readonly)
12 13 14 |
# File 'lib/trophy_api_client/types/leaderboard_ranking.rb', line 12 def user_name @user_name end |
#value ⇒ Integer (readonly)
16 17 18 |
# File 'lib/trophy_api_client/types/leaderboard_ranking.rb', line 16 def value @value end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::LeaderboardRanking
Deserialize a JSON object to an instance of LeaderboardRanking
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/trophy_api_client/types/leaderboard_ranking.rb', line 46 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) user_id = parsed_json["userId"] user_name = parsed_json["userName"] rank = parsed_json["rank"] value = parsed_json["value"] new( user_id: user_id, user_name: user_name, rank: rank, value: value, 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.
75 76 77 78 79 80 |
# File 'lib/trophy_api_client/types/leaderboard_ranking.rb', line 75 def self.validate_raw(obj:) obj.user_id.is_a?(String) != false || raise("Passed value for field obj.user_id is not the expected type, validation failed.") obj.user_name&.is_a?(String) != false || raise("Passed value for field obj.user_name is not the expected type, validation failed.") obj.rank.is_a?(Integer) != false || raise("Passed value for field obj.rank is not the expected type, validation failed.") obj.value.is_a?(Integer) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of LeaderboardRanking to a JSON object
65 66 67 |
# File 'lib/trophy_api_client/types/leaderboard_ranking.rb', line 65 def to_json(*_args) @_field_set&.to_json end |