Class: TrophyApiClient::LeaderboardEvent
- Inherits:
-
Object
- Object
- TrophyApiClient::LeaderboardEvent
- Defined in:
- lib/trophy_api_client/types/leaderboard_event.rb
Overview
A daily leaderboard snapshot entry representing the user’s rank/value state and
the previous persisted state.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#date ⇒ String
readonly
The leaderboard snapshot date in YYYY-MM-DD format.
-
#previous_rank ⇒ Integer
readonly
The user’s rank before this event, or null if they were not on the leaderboard.
-
#previous_value ⇒ Integer
readonly
The user’s value before this event, or null if they were not on the leaderboard.
-
#rank ⇒ Integer
readonly
The user’s rank after this event, or null if they are no longer on the leaderboard.
-
#timestamp ⇒ DateTime
readonly
Deprecated ISO timestamp for the snapshot day boundary.
-
#value ⇒ Integer
readonly
The user’s value after this event, or null if they are no longer on the leaderboard.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::LeaderboardEvent
Deserialize a JSON object to an instance of LeaderboardEvent.
-
.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(date:, timestamp:, previous_rank: OMIT, rank: OMIT, previous_value: OMIT, value: OMIT, additional_properties: nil) ⇒ TrophyApiClient::LeaderboardEvent constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of LeaderboardEvent to a JSON object.
Constructor Details
#initialize(date:, timestamp:, previous_rank: OMIT, rank: OMIT, previous_value: OMIT, value: OMIT, additional_properties: nil) ⇒ TrophyApiClient::LeaderboardEvent
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 43 def initialize(date:, timestamp:, previous_rank: OMIT, rank: OMIT, previous_value: OMIT, value: OMIT, additional_properties: nil) @date = date @timestamp = @previous_rank = previous_rank if previous_rank != OMIT @rank = rank if rank != OMIT @previous_value = previous_value if previous_value != OMIT @value = value if value != OMIT @additional_properties = additional_properties @_field_set = { "date": date, "timestamp": , "previousRank": previous_rank, "rank": rank, "previousValue": previous_value, "value": value }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
26 27 28 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 26 def additional_properties @additional_properties end |
#date ⇒ String (readonly)
Returns The leaderboard snapshot date in YYYY-MM-DD format.
12 13 14 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 12 def date @date end |
#previous_rank ⇒ Integer (readonly)
Returns The user’s rank before this event, or null if they were not on the leaderboard.
16 17 18 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 16 def previous_rank @previous_rank end |
#previous_value ⇒ Integer (readonly)
Returns The user’s value before this event, or null if they were not on the leaderboard.
21 22 23 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 21 def previous_value @previous_value end |
#rank ⇒ Integer (readonly)
Returns The user’s rank after this event, or null if they are no longer on the leaderboard.
19 20 21 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 19 def rank @rank end |
#timestamp ⇒ DateTime (readonly)
Returns Deprecated ISO timestamp for the snapshot day boundary. Use ‘date` instead.
14 15 16 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 14 def @timestamp end |
#value ⇒ Integer (readonly)
Returns The user’s value after this event, or null if they are no longer on the leaderboard.
24 25 26 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 24 def value @value end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::LeaderboardEvent
Deserialize a JSON object to an instance of LeaderboardEvent
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 68 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) date = parsed_json["date"] = (DateTime.parse(parsed_json["timestamp"]) unless parsed_json["timestamp"].nil?) previous_rank = parsed_json["previousRank"] rank = parsed_json["rank"] previous_value = parsed_json["previousValue"] value = parsed_json["value"] new( date: date, timestamp: , previous_rank: previous_rank, rank: rank, previous_value: previous_value, 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.
101 102 103 104 105 106 107 108 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 101 def self.validate_raw(obj:) obj.date.is_a?(String) != false || raise("Passed value for field obj.date is not the expected type, validation failed.") obj..is_a?(DateTime) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.") obj.previous_rank&.is_a?(Integer) != false || raise("Passed value for field obj.previous_rank 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.previous_value&.is_a?(Integer) != false || raise("Passed value for field obj.previous_value 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 LeaderboardEvent to a JSON object
91 92 93 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 91 def to_json(*_args) @_field_set&.to_json end |