Class: TrophyApiClient::WrappedMostActiveWeek

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

Overview

The user’s most active week during the year.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start:, end_:, metrics:, points:, achievements:, leaderboards:, additional_properties: nil) ⇒ TrophyApiClient::WrappedMostActiveWeek

Parameters:

  • The start date of the most active week in YYYY-MM-DD format.

  • The end date of the most active week in YYYY-MM-DD format.

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

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

  • Achievements completed during this period.

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

  • (defaults to: nil)

    Additional properties unmapped to the current class definition



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/trophy_api_client/types/wrapped_most_active_week.rb', line 40

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

Instance Attribute Details

#achievementsArray<TrophyApiClient::UserAchievementResponse> (readonly)

Returns Achievements completed during this period.

Returns:

  • Achievements completed during this period.



19
20
21
# File 'lib/trophy_api_client/types/wrapped_most_active_week.rb', line 19

def achievements
  @achievements
end

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • Additional properties unmapped to the current class definition



24
25
26
# File 'lib/trophy_api_client/types/wrapped_most_active_week.rb', line 24

def additional_properties
  @additional_properties
end

#end_String (readonly)

Returns The end date of the most active week in YYYY-MM-DD format.

Returns:

  • The end date of the most active week in YYYY-MM-DD format.



13
14
15
# File 'lib/trophy_api_client/types/wrapped_most_active_week.rb', line 13

def end_
  @end_
end

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

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

Returns:

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



22
23
24
# File 'lib/trophy_api_client/types/wrapped_most_active_week.rb', line 22

def leaderboards
  @leaderboards
end

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

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

Returns:

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



15
16
17
# File 'lib/trophy_api_client/types/wrapped_most_active_week.rb', line 15

def metrics
  @metrics
end

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

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

Returns:

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



17
18
19
# File 'lib/trophy_api_client/types/wrapped_most_active_week.rb', line 17

def points
  @points
end

#startString (readonly)

Returns The start date of the most active week in YYYY-MM-DD format.

Returns:

  • The start date of the most active week in YYYY-MM-DD format.



11
12
13
# File 'lib/trophy_api_client/types/wrapped_most_active_week.rb', line 11

def start
  @start
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::WrappedMostActiveWeek

Deserialize a JSON object to an instance of WrappedMostActiveWeek

Parameters:

Returns:



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
92
# File 'lib/trophy_api_client/types/wrapped_most_active_week.rb', line 62

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  start = parsed_json["start"]
  end_ = parsed_json["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(
    start: start,
    end_: end_,
    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:

Returns:



107
108
109
110
111
112
113
114
# File 'lib/trophy_api_client/types/wrapped_most_active_week.rb', line 107

def self.validate_raw(obj:)
  obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
  obj.end_.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
  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 WrappedMostActiveWeek to a JSON object

Returns:



97
98
99
# File 'lib/trophy_api_client/types/wrapped_most_active_week.rb', line 97

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