Class: TrophyApiClient::LeaderboardEvent
- Inherits:
-
Object
- Object
- TrophyApiClient::LeaderboardEvent
- Defined in:
- lib/trophy_api_client/types/leaderboard_event.rb
Overview
A leaderboard event representing a change in a user’s rank or value.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#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
The timestamp when the event occurred.
-
#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(timestamp: OMIT, 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(timestamp: OMIT, previous_rank: OMIT, rank: OMIT, previous_value: OMIT, value: OMIT, additional_properties: nil) ⇒ TrophyApiClient::LeaderboardEvent
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 39 def initialize(timestamp: OMIT, previous_rank: OMIT, rank: OMIT, previous_value: OMIT, value: OMIT, additional_properties: nil) = if != OMIT @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 = { "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)
23 24 25 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 23 def additional_properties @additional_properties end |
#previous_rank ⇒ Integer (readonly)
13 14 15 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 13 def previous_rank @previous_rank end |
#previous_value ⇒ Integer (readonly)
18 19 20 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 18 def previous_value @previous_value end |
#rank ⇒ Integer (readonly)
16 17 18 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 16 def rank @rank end |
#timestamp ⇒ DateTime (readonly)
11 12 13 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 11 def end |
#value ⇒ Integer (readonly)
21 22 23 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 21 def value @value end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::LeaderboardEvent
Deserialize a JSON object to an instance of LeaderboardEvent
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 62 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) = (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( 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.
93 94 95 96 97 98 99 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 93 def self.validate_raw(obj:) 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
83 84 85 |
# File 'lib/trophy_api_client/types/leaderboard_event.rb', line 83 def to_json(*_args) @_field_set&.to_json end |