Class: TrophyApiClient::WrappedActivityPeriod
- Inherits:
-
Object
- Object
- TrophyApiClient::WrappedActivityPeriod
- Defined in:
- lib/trophy_api_client/types/wrapped_activity_period.rb
Overview
Activity data for a specific period (day, week, month, or year).
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#achievements ⇒ Array<TrophyApiClient::UserAchievementResponse>
readonly
Achievements completed during this period.
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#leaderboards ⇒ Hash{String => TrophyApiClient::UserLeaderboardResponse}
readonly
The user’s best leaderboard rankings during this period, keyed by leaderboard key.
-
#metrics ⇒ Hash{String => TrophyApiClient::WrappedMetric}
readonly
The user’s metrics during this period, keyed by metric key.
-
#points ⇒ Hash{String => TrophyApiClient::WrappedPoints}
readonly
The user’s points during this period, keyed by points system key.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::WrappedActivityPeriod
Deserialize a JSON object to an instance of WrappedActivityPeriod.
-
.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(metrics:, points:, achievements:, leaderboards:, additional_properties: nil) ⇒ TrophyApiClient::WrappedActivityPeriod constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of WrappedActivityPeriod to a JSON object.
Constructor Details
#initialize(metrics:, points:, achievements:, leaderboards:, additional_properties: nil) ⇒ TrophyApiClient::WrappedActivityPeriod
34 35 36 37 38 39 40 41 |
# File 'lib/trophy_api_client/types/wrapped_activity_period.rb', line 34 def initialize(metrics:, points:, achievements:, leaderboards:, additional_properties: nil) @metrics = metrics @points = points @achievements = achievements @leaderboards = leaderboards @additional_properties = additional_properties @_field_set = { "metrics": metrics, "points": points, "achievements": achievements, "leaderboards": leaderboards } end |
Instance Attribute Details
#achievements ⇒ Array<TrophyApiClient::UserAchievementResponse> (readonly)
Returns Achievements completed during this period.
15 16 17 |
# File 'lib/trophy_api_client/types/wrapped_activity_period.rb', line 15 def achievements @achievements end |
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
20 21 22 |
# File 'lib/trophy_api_client/types/wrapped_activity_period.rb', line 20 def additional_properties @additional_properties end |
#leaderboards ⇒ Hash{String => TrophyApiClient::UserLeaderboardResponse} (readonly)
Returns The user’s best leaderboard rankings during this period, keyed by leaderboard key.
18 19 20 |
# File 'lib/trophy_api_client/types/wrapped_activity_period.rb', line 18 def leaderboards @leaderboards end |
#metrics ⇒ Hash{String => TrophyApiClient::WrappedMetric} (readonly)
Returns The user’s metrics during this period, keyed by metric key.
11 12 13 |
# File 'lib/trophy_api_client/types/wrapped_activity_period.rb', line 11 def metrics @metrics end |
#points ⇒ Hash{String => TrophyApiClient::WrappedPoints} (readonly)
Returns The user’s points during this period, keyed by points system key.
13 14 15 |
# File 'lib/trophy_api_client/types/wrapped_activity_period.rb', line 13 def points @points end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::WrappedActivityPeriod
Deserialize a JSON object to an instance of WrappedActivityPeriod
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/trophy_api_client/types/wrapped_activity_period.rb', line 47 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) metrics = parsed_json["metrics"]&.transform_values do |value| value = value.to_json TrophyApiClient::WrappedMetric.from_json(json_object: value) end points = parsed_json["points"]&.transform_values do |value| value = value.to_json TrophyApiClient::WrappedPoints.from_json(json_object: value) end achievements = parsed_json["achievements"]&.map do |item| item = item.to_json TrophyApiClient::UserAchievementResponse.from_json(json_object: item) end leaderboards = parsed_json["leaderboards"]&.transform_values do |value| value = value.to_json TrophyApiClient::UserLeaderboardResponse.from_json(json_object: value) end new( metrics: metrics, points: points, achievements: achievements, leaderboards: leaderboards, 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.
88 89 90 91 92 93 |
# File 'lib/trophy_api_client/types/wrapped_activity_period.rb', line 88 def self.validate_raw(obj:) obj.metrics.is_a?(Hash) != false || raise("Passed value for field obj.metrics is not the expected type, validation failed.") obj.points.is_a?(Hash) != false || raise("Passed value for field obj.points is not the expected type, validation failed.") obj.achievements.is_a?(Array) != false || raise("Passed value for field obj.achievements is not the expected type, validation failed.") obj.leaderboards.is_a?(Hash) != false || raise("Passed value for field obj.leaderboards is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of WrappedActivityPeriod to a JSON object
78 79 80 |
# File 'lib/trophy_api_client/types/wrapped_activity_period.rb', line 78 def to_json(*_args) @_field_set&.to_json end |