Class: TrophyApiClient::WrappedEntireYear

Inherits:
Object
  • Object
show all
Defined in:
lib/trophy_api_client/types/wrapped_entire_year.rb

Overview

The user’s activity data for the entire year.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(longest_streak:, metrics:, points:, achievements:, leaderboards:, additional_properties: nil) ⇒ TrophyApiClient::WrappedEntireYear

Parameters:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/trophy_api_client/types/wrapped_entire_year.rb', line 38

def initialize(longest_streak:, metrics:, points:, achievements:, leaderboards:, additional_properties: nil)
  @longest_streak = longest_streak
  @metrics = metrics
  @points = points
  @achievements = achievements
  @leaderboards = leaderboards
  @additional_properties = additional_properties
  @_field_set = {
    "longestStreak": longest_streak,
    "metrics": metrics,
    "points": points,
    "achievements": achievements,
    "leaderboards": leaderboards
  }
end

Instance Attribute Details

#achievementsArray<TrophyApiClient::UserAchievementResponse> (readonly)

Returns Achievements completed during this period.

Returns:



18
19
20
# File 'lib/trophy_api_client/types/wrapped_entire_year.rb', line 18

def achievements
  @achievements
end

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



23
24
25
# File 'lib/trophy_api_client/types/wrapped_entire_year.rb', line 23

def additional_properties
  @additional_properties
end

#leaderboardsHash{String => TrophyApiClient::UserLeaderboardResponse} (readonly)

Returns The user’s best leaderboard rankings during this period, keyed by leaderboard key.

Returns:



21
22
23
# File 'lib/trophy_api_client/types/wrapped_entire_year.rb', line 21

def leaderboards
  @leaderboards
end

#longest_streakTrophyApiClient::WrappedStreak (readonly)

Returns The user’s longest streak during the year.

Returns:



12
13
14
# File 'lib/trophy_api_client/types/wrapped_entire_year.rb', line 12

def longest_streak
  @longest_streak
end

#metricsHash{String => TrophyApiClient::WrappedMetric} (readonly)

Returns The user’s metrics during this period, keyed by metric key.

Returns:



14
15
16
# File 'lib/trophy_api_client/types/wrapped_entire_year.rb', line 14

def metrics
  @metrics
end

#pointsHash{String => TrophyApiClient::WrappedPoints} (readonly)

Returns The user’s points during this period, keyed by points system key.

Returns:



16
17
18
# File 'lib/trophy_api_client/types/wrapped_entire_year.rb', line 16

def points
  @points
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::WrappedEntireYear

Deserialize a JSON object to an instance of WrappedEntireYear

Parameters:

  • json_object (String)

Returns:



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/trophy_api_client/types/wrapped_entire_year.rb', line 58

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["longestStreak"].nil?
    longest_streak = nil
  else
    longest_streak = parsed_json["longestStreak"].to_json
    longest_streak = TrophyApiClient::WrappedStreak.from_json(json_object: longest_streak)
  end
  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(
    longest_streak: longest_streak,
    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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


106
107
108
109
110
111
112
# File 'lib/trophy_api_client/types/wrapped_entire_year.rb', line 106

def self.validate_raw(obj:)
  TrophyApiClient::WrappedStreak.validate_raw(obj: obj.longest_streak)
  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 WrappedEntireYear to a JSON object

Returns:

  • (String)


96
97
98
# File 'lib/trophy_api_client/types/wrapped_entire_year.rb', line 96

def to_json(*_args)
  @_field_set&.to_json
end