trophy_api_client 1.0.36 → 1.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "completed_achievement_response"
4
+ require "ostruct"
5
+ require "json"
6
+
7
+ module TrophyApiClient
8
+ # Activity data for a specific period (day, week, month, or year).
9
+ class WrappedActivityPeriod
10
+ # @return [Hash{String => TrophyApiClient::WrappedMetric}] The user's metrics during this period, keyed by metric key.
11
+ attr_reader :metrics
12
+ # @return [Hash{String => TrophyApiClient::WrappedPoints}] The user's points during this period, keyed by points system key.
13
+ attr_reader :points
14
+ # @return [Array<TrophyApiClient::CompletedAchievementResponse>] Achievements completed during this period.
15
+ attr_reader :achievements
16
+ # @return [Hash{String => TrophyApiClient::UserLeaderboardResponse}] The user's best leaderboard rankings during this period, keyed by leaderboard
17
+ # key.
18
+ attr_reader :leaderboards
19
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
20
+ attr_reader :additional_properties
21
+ # @return [Object]
22
+ attr_reader :_field_set
23
+ protected :_field_set
24
+
25
+ OMIT = Object.new
26
+
27
+ # @param metrics [Hash{String => TrophyApiClient::WrappedMetric}] The user's metrics during this period, keyed by metric key.
28
+ # @param points [Hash{String => TrophyApiClient::WrappedPoints}] The user's points during this period, keyed by points system key.
29
+ # @param achievements [Array<TrophyApiClient::CompletedAchievementResponse>] Achievements completed during this period.
30
+ # @param leaderboards [Hash{String => TrophyApiClient::UserLeaderboardResponse}] The user's best leaderboard rankings during this period, keyed by leaderboard
31
+ # key.
32
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
33
+ # @return [TrophyApiClient::WrappedActivityPeriod]
34
+ def initialize(metrics:, points:, achievements:, leaderboards:, additional_properties: nil)
35
+ @metrics = metrics
36
+ @points = points
37
+ @achievements = achievements
38
+ @leaderboards = leaderboards
39
+ @additional_properties = additional_properties
40
+ @_field_set = { "metrics": metrics, "points": points, "achievements": achievements, "leaderboards": leaderboards }
41
+ end
42
+
43
+ # Deserialize a JSON object to an instance of WrappedActivityPeriod
44
+ #
45
+ # @param json_object [String]
46
+ # @return [TrophyApiClient::WrappedActivityPeriod]
47
+ def self.from_json(json_object:)
48
+ struct = JSON.parse(json_object, object_class: OpenStruct)
49
+ parsed_json = JSON.parse(json_object)
50
+ metrics = parsed_json["metrics"]&.transform_values do |value|
51
+ value = value.to_json
52
+ TrophyApiClient::WrappedMetric.from_json(json_object: value)
53
+ end
54
+ points = parsed_json["points"]&.transform_values do |value|
55
+ value = value.to_json
56
+ TrophyApiClient::WrappedPoints.from_json(json_object: value)
57
+ end
58
+ achievements = parsed_json["achievements"]&.map do |item|
59
+ item = item.to_json
60
+ TrophyApiClient::CompletedAchievementResponse.from_json(json_object: item)
61
+ end
62
+ leaderboards = parsed_json["leaderboards"]&.transform_values do |value|
63
+ value = value.to_json
64
+ TrophyApiClient::UserLeaderboardResponse.from_json(json_object: value)
65
+ end
66
+ new(
67
+ metrics: metrics,
68
+ points: points,
69
+ achievements: achievements,
70
+ leaderboards: leaderboards,
71
+ additional_properties: struct
72
+ )
73
+ end
74
+
75
+ # Serialize an instance of WrappedActivityPeriod to a JSON object
76
+ #
77
+ # @return [String]
78
+ def to_json(*_args)
79
+ @_field_set&.to_json
80
+ end
81
+
82
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
83
+ # hash and check each fields type against the current object's property
84
+ # definitions.
85
+ #
86
+ # @param obj [Object]
87
+ # @return [Void]
88
+ def self.validate_raw(obj:)
89
+ obj.metrics.is_a?(Hash) != false || raise("Passed value for field obj.metrics is not the expected type, validation failed.")
90
+ obj.points.is_a?(Hash) != false || raise("Passed value for field obj.points is not the expected type, validation failed.")
91
+ obj.achievements.is_a?(Array) != false || raise("Passed value for field obj.achievements is not the expected type, validation failed.")
92
+ obj.leaderboards.is_a?(Hash) != false || raise("Passed value for field obj.leaderboards is not the expected type, validation failed.")
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "wrapped_streak"
4
+ require_relative "completed_achievement_response"
5
+ require "ostruct"
6
+ require "json"
7
+
8
+ module TrophyApiClient
9
+ # The user's activity data for the entire year.
10
+ class WrappedEntireYear
11
+ # @return [TrophyApiClient::WrappedStreak] The user's longest streak during the year.
12
+ attr_reader :longest_streak
13
+ # @return [Hash{String => TrophyApiClient::WrappedMetric}] The user's metrics during this period, keyed by metric key.
14
+ attr_reader :metrics
15
+ # @return [Hash{String => TrophyApiClient::WrappedPoints}] The user's points during this period, keyed by points system key.
16
+ attr_reader :points
17
+ # @return [Array<TrophyApiClient::CompletedAchievementResponse>] Achievements completed during this period.
18
+ attr_reader :achievements
19
+ # @return [Hash{String => TrophyApiClient::UserLeaderboardResponse}] The user's best leaderboard rankings during this period, keyed by leaderboard
20
+ # key.
21
+ attr_reader :leaderboards
22
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
23
+ attr_reader :additional_properties
24
+ # @return [Object]
25
+ attr_reader :_field_set
26
+ protected :_field_set
27
+
28
+ OMIT = Object.new
29
+
30
+ # @param longest_streak [TrophyApiClient::WrappedStreak] The user's longest streak during the year.
31
+ # @param metrics [Hash{String => TrophyApiClient::WrappedMetric}] The user's metrics during this period, keyed by metric key.
32
+ # @param points [Hash{String => TrophyApiClient::WrappedPoints}] The user's points during this period, keyed by points system key.
33
+ # @param achievements [Array<TrophyApiClient::CompletedAchievementResponse>] Achievements completed during this period.
34
+ # @param leaderboards [Hash{String => TrophyApiClient::UserLeaderboardResponse}] The user's best leaderboard rankings during this period, keyed by leaderboard
35
+ # key.
36
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
37
+ # @return [TrophyApiClient::WrappedEntireYear]
38
+ def initialize(longest_streak:, metrics:, points:, achievements:, leaderboards:, additional_properties: nil)
39
+ @longest_streak = longest_streak
40
+ @metrics = metrics
41
+ @points = points
42
+ @achievements = achievements
43
+ @leaderboards = leaderboards
44
+ @additional_properties = additional_properties
45
+ @_field_set = {
46
+ "longestStreak": longest_streak,
47
+ "metrics": metrics,
48
+ "points": points,
49
+ "achievements": achievements,
50
+ "leaderboards": leaderboards
51
+ }
52
+ end
53
+
54
+ # Deserialize a JSON object to an instance of WrappedEntireYear
55
+ #
56
+ # @param json_object [String]
57
+ # @return [TrophyApiClient::WrappedEntireYear]
58
+ def self.from_json(json_object:)
59
+ struct = JSON.parse(json_object, object_class: OpenStruct)
60
+ parsed_json = JSON.parse(json_object)
61
+ if parsed_json["longestStreak"].nil?
62
+ longest_streak = nil
63
+ else
64
+ longest_streak = parsed_json["longestStreak"].to_json
65
+ longest_streak = TrophyApiClient::WrappedStreak.from_json(json_object: longest_streak)
66
+ end
67
+ metrics = parsed_json["metrics"]&.transform_values do |value|
68
+ value = value.to_json
69
+ TrophyApiClient::WrappedMetric.from_json(json_object: value)
70
+ end
71
+ points = parsed_json["points"]&.transform_values do |value|
72
+ value = value.to_json
73
+ TrophyApiClient::WrappedPoints.from_json(json_object: value)
74
+ end
75
+ achievements = parsed_json["achievements"]&.map do |item|
76
+ item = item.to_json
77
+ TrophyApiClient::CompletedAchievementResponse.from_json(json_object: item)
78
+ end
79
+ leaderboards = parsed_json["leaderboards"]&.transform_values do |value|
80
+ value = value.to_json
81
+ TrophyApiClient::UserLeaderboardResponse.from_json(json_object: value)
82
+ end
83
+ new(
84
+ longest_streak: longest_streak,
85
+ metrics: metrics,
86
+ points: points,
87
+ achievements: achievements,
88
+ leaderboards: leaderboards,
89
+ additional_properties: struct
90
+ )
91
+ end
92
+
93
+ # Serialize an instance of WrappedEntireYear to a JSON object
94
+ #
95
+ # @return [String]
96
+ def to_json(*_args)
97
+ @_field_set&.to_json
98
+ end
99
+
100
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
101
+ # hash and check each fields type against the current object's property
102
+ # definitions.
103
+ #
104
+ # @param obj [Object]
105
+ # @return [Void]
106
+ def self.validate_raw(obj:)
107
+ TrophyApiClient::WrappedStreak.validate_raw(obj: obj.longest_streak)
108
+ obj.metrics.is_a?(Hash) != false || raise("Passed value for field obj.metrics is not the expected type, validation failed.")
109
+ obj.points.is_a?(Hash) != false || raise("Passed value for field obj.points is not the expected type, validation failed.")
110
+ obj.achievements.is_a?(Array) != false || raise("Passed value for field obj.achievements is not the expected type, validation failed.")
111
+ obj.leaderboards.is_a?(Hash) != false || raise("Passed value for field obj.leaderboards is not the expected type, validation failed.")
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,119 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module TrophyApiClient
7
+ # A user's metric data for a wrapped period.
8
+ class WrappedMetric
9
+ # @return [String] The name of the metric.
10
+ attr_reader :name
11
+ # @return [String] The units of the metric.
12
+ attr_reader :units
13
+ # @return [Float] The user's current total for the metric.
14
+ attr_reader :current_total
15
+ # @return [Float] The change in the metric value during the period.
16
+ attr_reader :change_this_period
17
+ # @return [Float] The percentage change in the metric value during the period.
18
+ attr_reader :percent_change
19
+ # @return [Float] The user's percentile rank for this metric during the period. Only included for
20
+ # weekly, monthly, and yearly aggregation periods.
21
+ attr_reader :percentile_this_period
22
+ # @return [Hash{String => Hash}] Metric data broken down by attribute key and value.
23
+ attr_reader :by_attribute
24
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
25
+ attr_reader :additional_properties
26
+ # @return [Object]
27
+ attr_reader :_field_set
28
+ protected :_field_set
29
+
30
+ OMIT = Object.new
31
+
32
+ # @param name [String] The name of the metric.
33
+ # @param units [String] The units of the metric.
34
+ # @param current_total [Float] The user's current total for the metric.
35
+ # @param change_this_period [Float] The change in the metric value during the period.
36
+ # @param percent_change [Float] The percentage change in the metric value during the period.
37
+ # @param percentile_this_period [Float] The user's percentile rank for this metric during the period. Only included for
38
+ # weekly, monthly, and yearly aggregation periods.
39
+ # @param by_attribute [Hash{String => Hash}] Metric data broken down by attribute key and value.
40
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
41
+ # @return [TrophyApiClient::WrappedMetric]
42
+ def initialize(name:, current_total:, change_this_period:, percent_change:, by_attribute:, units: OMIT,
43
+ percentile_this_period: OMIT, additional_properties: nil)
44
+ @name = name
45
+ @units = units if units != OMIT
46
+ @current_total = current_total
47
+ @change_this_period = change_this_period
48
+ @percent_change = percent_change
49
+ @percentile_this_period = percentile_this_period if percentile_this_period != OMIT
50
+ @by_attribute = by_attribute
51
+ @additional_properties = additional_properties
52
+ @_field_set = {
53
+ "name": name,
54
+ "units": units,
55
+ "currentTotal": current_total,
56
+ "changeThisPeriod": change_this_period,
57
+ "percentChange": percent_change,
58
+ "percentileThisPeriod": percentile_this_period,
59
+ "byAttribute": by_attribute
60
+ }.reject do |_k, v|
61
+ v == OMIT
62
+ end
63
+ end
64
+
65
+ # Deserialize a JSON object to an instance of WrappedMetric
66
+ #
67
+ # @param json_object [String]
68
+ # @return [TrophyApiClient::WrappedMetric]
69
+ def self.from_json(json_object:)
70
+ struct = JSON.parse(json_object, object_class: OpenStruct)
71
+ parsed_json = JSON.parse(json_object)
72
+ name = parsed_json["name"]
73
+ units = parsed_json["units"]
74
+ current_total = parsed_json["currentTotal"]
75
+ change_this_period = parsed_json["changeThisPeriod"]
76
+ percent_change = parsed_json["percentChange"]
77
+ percentile_this_period = parsed_json["percentileThisPeriod"]
78
+ by_attribute = parsed_json["byAttribute"]&.transform_values do |value|
79
+ value&.transform_values do |value|
80
+ value = value.to_json
81
+ TrophyApiClient::WrappedMetricByAttributeValueValue.from_json(json_object: value)
82
+ end
83
+ end
84
+ new(
85
+ name: name,
86
+ units: units,
87
+ current_total: current_total,
88
+ change_this_period: change_this_period,
89
+ percent_change: percent_change,
90
+ percentile_this_period: percentile_this_period,
91
+ by_attribute: by_attribute,
92
+ additional_properties: struct
93
+ )
94
+ end
95
+
96
+ # Serialize an instance of WrappedMetric to a JSON object
97
+ #
98
+ # @return [String]
99
+ def to_json(*_args)
100
+ @_field_set&.to_json
101
+ end
102
+
103
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
104
+ # hash and check each fields type against the current object's property
105
+ # definitions.
106
+ #
107
+ # @param obj [Object]
108
+ # @return [Void]
109
+ def self.validate_raw(obj:)
110
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
111
+ obj.units&.is_a?(String) != false || raise("Passed value for field obj.units is not the expected type, validation failed.")
112
+ obj.current_total.is_a?(Float) != false || raise("Passed value for field obj.current_total is not the expected type, validation failed.")
113
+ obj.change_this_period.is_a?(Float) != false || raise("Passed value for field obj.change_this_period is not the expected type, validation failed.")
114
+ obj.percent_change.is_a?(Float) != false || raise("Passed value for field obj.percent_change is not the expected type, validation failed.")
115
+ obj.percentile_this_period&.is_a?(Float) != false || raise("Passed value for field obj.percentile_this_period is not the expected type, validation failed.")
116
+ obj.by_attribute.is_a?(Hash) != false || raise("Passed value for field obj.by_attribute is not the expected type, validation failed.")
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module TrophyApiClient
7
+ class WrappedMetricByAttributeValueValue
8
+ # @return [String] The name of the metric.
9
+ attr_reader :name
10
+ # @return [String] The units of the metric.
11
+ attr_reader :units
12
+ # @return [Float] The current total for this attribute value.
13
+ attr_reader :current_total
14
+ # @return [Float] The change during the period for this attribute value.
15
+ attr_reader :change_this_period
16
+ # @return [Float] The percentage change for this attribute value.
17
+ attr_reader :percent_change
18
+ # @return [Float] The user's percentile rank for this attribute value during the period.
19
+ attr_reader :percentile_this_period
20
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
21
+ attr_reader :additional_properties
22
+ # @return [Object]
23
+ attr_reader :_field_set
24
+ protected :_field_set
25
+
26
+ OMIT = Object.new
27
+
28
+ # @param name [String] The name of the metric.
29
+ # @param units [String] The units of the metric.
30
+ # @param current_total [Float] The current total for this attribute value.
31
+ # @param change_this_period [Float] The change during the period for this attribute value.
32
+ # @param percent_change [Float] The percentage change for this attribute value.
33
+ # @param percentile_this_period [Float] The user's percentile rank for this attribute value during the period.
34
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
35
+ # @return [TrophyApiClient::WrappedMetricByAttributeValueValue]
36
+ def initialize(name: OMIT, units: OMIT, current_total: OMIT, change_this_period: OMIT, percent_change: OMIT,
37
+ percentile_this_period: OMIT, additional_properties: nil)
38
+ @name = name if name != OMIT
39
+ @units = units if units != OMIT
40
+ @current_total = current_total if current_total != OMIT
41
+ @change_this_period = change_this_period if change_this_period != OMIT
42
+ @percent_change = percent_change if percent_change != OMIT
43
+ @percentile_this_period = percentile_this_period if percentile_this_period != OMIT
44
+ @additional_properties = additional_properties
45
+ @_field_set = {
46
+ "name": name,
47
+ "units": units,
48
+ "currentTotal": current_total,
49
+ "changeThisPeriod": change_this_period,
50
+ "percentChange": percent_change,
51
+ "percentileThisPeriod": percentile_this_period
52
+ }.reject do |_k, v|
53
+ v == OMIT
54
+ end
55
+ end
56
+
57
+ # Deserialize a JSON object to an instance of WrappedMetricByAttributeValueValue
58
+ #
59
+ # @param json_object [String]
60
+ # @return [TrophyApiClient::WrappedMetricByAttributeValueValue]
61
+ def self.from_json(json_object:)
62
+ struct = JSON.parse(json_object, object_class: OpenStruct)
63
+ parsed_json = JSON.parse(json_object)
64
+ name = parsed_json["name"]
65
+ units = parsed_json["units"]
66
+ current_total = parsed_json["currentTotal"]
67
+ change_this_period = parsed_json["changeThisPeriod"]
68
+ percent_change = parsed_json["percentChange"]
69
+ percentile_this_period = parsed_json["percentileThisPeriod"]
70
+ new(
71
+ name: name,
72
+ units: units,
73
+ current_total: current_total,
74
+ change_this_period: change_this_period,
75
+ percent_change: percent_change,
76
+ percentile_this_period: percentile_this_period,
77
+ additional_properties: struct
78
+ )
79
+ end
80
+
81
+ # Serialize an instance of WrappedMetricByAttributeValueValue to a JSON object
82
+ #
83
+ # @return [String]
84
+ def to_json(*_args)
85
+ @_field_set&.to_json
86
+ end
87
+
88
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
89
+ # hash and check each fields type against the current object's property
90
+ # definitions.
91
+ #
92
+ # @param obj [Object]
93
+ # @return [Void]
94
+ def self.validate_raw(obj:)
95
+ obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
96
+ obj.units&.is_a?(String) != false || raise("Passed value for field obj.units is not the expected type, validation failed.")
97
+ obj.current_total&.is_a?(Float) != false || raise("Passed value for field obj.current_total is not the expected type, validation failed.")
98
+ obj.change_this_period&.is_a?(Float) != false || raise("Passed value for field obj.change_this_period is not the expected type, validation failed.")
99
+ obj.percent_change&.is_a?(Float) != false || raise("Passed value for field obj.percent_change is not the expected type, validation failed.")
100
+ obj.percentile_this_period&.is_a?(Float) != false || raise("Passed value for field obj.percentile_this_period is not the expected type, validation failed.")
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,108 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "completed_achievement_response"
4
+ require "ostruct"
5
+ require "json"
6
+
7
+ module TrophyApiClient
8
+ # The user's most active day during the year.
9
+ class WrappedMostActiveDay
10
+ # @return [String] The date of the most active day in YYYY-MM-DD format.
11
+ attr_reader :date
12
+ # @return [Hash{String => TrophyApiClient::WrappedMetric}] The user's metrics during this period, keyed by metric key.
13
+ attr_reader :metrics
14
+ # @return [Hash{String => TrophyApiClient::WrappedPoints}] The user's points during this period, keyed by points system key.
15
+ attr_reader :points
16
+ # @return [Array<TrophyApiClient::CompletedAchievementResponse>] Achievements completed during this period.
17
+ attr_reader :achievements
18
+ # @return [Hash{String => TrophyApiClient::UserLeaderboardResponse}] The user's best leaderboard rankings during this period, keyed by leaderboard
19
+ # key.
20
+ attr_reader :leaderboards
21
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
22
+ attr_reader :additional_properties
23
+ # @return [Object]
24
+ attr_reader :_field_set
25
+ protected :_field_set
26
+
27
+ OMIT = Object.new
28
+
29
+ # @param date [String] The date of the most active day in YYYY-MM-DD format.
30
+ # @param metrics [Hash{String => TrophyApiClient::WrappedMetric}] The user's metrics during this period, keyed by metric key.
31
+ # @param points [Hash{String => TrophyApiClient::WrappedPoints}] The user's points during this period, keyed by points system key.
32
+ # @param achievements [Array<TrophyApiClient::CompletedAchievementResponse>] Achievements completed during this period.
33
+ # @param leaderboards [Hash{String => TrophyApiClient::UserLeaderboardResponse}] The user's best leaderboard rankings during this period, keyed by leaderboard
34
+ # key.
35
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
36
+ # @return [TrophyApiClient::WrappedMostActiveDay]
37
+ def initialize(date:, metrics:, points:, achievements:, leaderboards:, additional_properties: nil)
38
+ @date = date
39
+ @metrics = metrics
40
+ @points = points
41
+ @achievements = achievements
42
+ @leaderboards = leaderboards
43
+ @additional_properties = additional_properties
44
+ @_field_set = {
45
+ "date": date,
46
+ "metrics": metrics,
47
+ "points": points,
48
+ "achievements": achievements,
49
+ "leaderboards": leaderboards
50
+ }
51
+ end
52
+
53
+ # Deserialize a JSON object to an instance of WrappedMostActiveDay
54
+ #
55
+ # @param json_object [String]
56
+ # @return [TrophyApiClient::WrappedMostActiveDay]
57
+ def self.from_json(json_object:)
58
+ struct = JSON.parse(json_object, object_class: OpenStruct)
59
+ parsed_json = JSON.parse(json_object)
60
+ date = parsed_json["date"]
61
+ metrics = parsed_json["metrics"]&.transform_values do |value|
62
+ value = value.to_json
63
+ TrophyApiClient::WrappedMetric.from_json(json_object: value)
64
+ end
65
+ points = parsed_json["points"]&.transform_values do |value|
66
+ value = value.to_json
67
+ TrophyApiClient::WrappedPoints.from_json(json_object: value)
68
+ end
69
+ achievements = parsed_json["achievements"]&.map do |item|
70
+ item = item.to_json
71
+ TrophyApiClient::CompletedAchievementResponse.from_json(json_object: item)
72
+ end
73
+ leaderboards = parsed_json["leaderboards"]&.transform_values do |value|
74
+ value = value.to_json
75
+ TrophyApiClient::UserLeaderboardResponse.from_json(json_object: value)
76
+ end
77
+ new(
78
+ date: date,
79
+ metrics: metrics,
80
+ points: points,
81
+ achievements: achievements,
82
+ leaderboards: leaderboards,
83
+ additional_properties: struct
84
+ )
85
+ end
86
+
87
+ # Serialize an instance of WrappedMostActiveDay to a JSON object
88
+ #
89
+ # @return [String]
90
+ def to_json(*_args)
91
+ @_field_set&.to_json
92
+ end
93
+
94
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
95
+ # hash and check each fields type against the current object's property
96
+ # definitions.
97
+ #
98
+ # @param obj [Object]
99
+ # @return [Void]
100
+ def self.validate_raw(obj:)
101
+ obj.date.is_a?(String) != false || raise("Passed value for field obj.date is not the expected type, validation failed.")
102
+ obj.metrics.is_a?(Hash) != false || raise("Passed value for field obj.metrics is not the expected type, validation failed.")
103
+ obj.points.is_a?(Hash) != false || raise("Passed value for field obj.points is not the expected type, validation failed.")
104
+ obj.achievements.is_a?(Array) != false || raise("Passed value for field obj.achievements is not the expected type, validation failed.")
105
+ obj.leaderboards.is_a?(Hash) != false || raise("Passed value for field obj.leaderboards is not the expected type, validation failed.")
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,108 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "completed_achievement_response"
4
+ require "ostruct"
5
+ require "json"
6
+
7
+ module TrophyApiClient
8
+ # The user's most active month during the year.
9
+ class WrappedMostActiveMonth
10
+ # @return [Integer] The month number (0-11, where 0 is January).
11
+ attr_reader :month
12
+ # @return [Hash{String => TrophyApiClient::WrappedMetric}] The user's metrics during this period, keyed by metric key.
13
+ attr_reader :metrics
14
+ # @return [Hash{String => TrophyApiClient::WrappedPoints}] The user's points during this period, keyed by points system key.
15
+ attr_reader :points
16
+ # @return [Array<TrophyApiClient::CompletedAchievementResponse>] Achievements completed during this period.
17
+ attr_reader :achievements
18
+ # @return [Hash{String => TrophyApiClient::UserLeaderboardResponse}] The user's best leaderboard rankings during this period, keyed by leaderboard
19
+ # key.
20
+ attr_reader :leaderboards
21
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
22
+ attr_reader :additional_properties
23
+ # @return [Object]
24
+ attr_reader :_field_set
25
+ protected :_field_set
26
+
27
+ OMIT = Object.new
28
+
29
+ # @param month [Integer] The month number (0-11, where 0 is January).
30
+ # @param metrics [Hash{String => TrophyApiClient::WrappedMetric}] The user's metrics during this period, keyed by metric key.
31
+ # @param points [Hash{String => TrophyApiClient::WrappedPoints}] The user's points during this period, keyed by points system key.
32
+ # @param achievements [Array<TrophyApiClient::CompletedAchievementResponse>] Achievements completed during this period.
33
+ # @param leaderboards [Hash{String => TrophyApiClient::UserLeaderboardResponse}] The user's best leaderboard rankings during this period, keyed by leaderboard
34
+ # key.
35
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
36
+ # @return [TrophyApiClient::WrappedMostActiveMonth]
37
+ def initialize(month:, metrics:, points:, achievements:, leaderboards:, additional_properties: nil)
38
+ @month = month
39
+ @metrics = metrics
40
+ @points = points
41
+ @achievements = achievements
42
+ @leaderboards = leaderboards
43
+ @additional_properties = additional_properties
44
+ @_field_set = {
45
+ "month": month,
46
+ "metrics": metrics,
47
+ "points": points,
48
+ "achievements": achievements,
49
+ "leaderboards": leaderboards
50
+ }
51
+ end
52
+
53
+ # Deserialize a JSON object to an instance of WrappedMostActiveMonth
54
+ #
55
+ # @param json_object [String]
56
+ # @return [TrophyApiClient::WrappedMostActiveMonth]
57
+ def self.from_json(json_object:)
58
+ struct = JSON.parse(json_object, object_class: OpenStruct)
59
+ parsed_json = JSON.parse(json_object)
60
+ month = parsed_json["month"]
61
+ metrics = parsed_json["metrics"]&.transform_values do |value|
62
+ value = value.to_json
63
+ TrophyApiClient::WrappedMetric.from_json(json_object: value)
64
+ end
65
+ points = parsed_json["points"]&.transform_values do |value|
66
+ value = value.to_json
67
+ TrophyApiClient::WrappedPoints.from_json(json_object: value)
68
+ end
69
+ achievements = parsed_json["achievements"]&.map do |item|
70
+ item = item.to_json
71
+ TrophyApiClient::CompletedAchievementResponse.from_json(json_object: item)
72
+ end
73
+ leaderboards = parsed_json["leaderboards"]&.transform_values do |value|
74
+ value = value.to_json
75
+ TrophyApiClient::UserLeaderboardResponse.from_json(json_object: value)
76
+ end
77
+ new(
78
+ month: month,
79
+ metrics: metrics,
80
+ points: points,
81
+ achievements: achievements,
82
+ leaderboards: leaderboards,
83
+ additional_properties: struct
84
+ )
85
+ end
86
+
87
+ # Serialize an instance of WrappedMostActiveMonth to a JSON object
88
+ #
89
+ # @return [String]
90
+ def to_json(*_args)
91
+ @_field_set&.to_json
92
+ end
93
+
94
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
95
+ # hash and check each fields type against the current object's property
96
+ # definitions.
97
+ #
98
+ # @param obj [Object]
99
+ # @return [Void]
100
+ def self.validate_raw(obj:)
101
+ obj.month.is_a?(Integer) != false || raise("Passed value for field obj.month is not the expected type, validation failed.")
102
+ obj.metrics.is_a?(Hash) != false || raise("Passed value for field obj.metrics is not the expected type, validation failed.")
103
+ obj.points.is_a?(Hash) != false || raise("Passed value for field obj.points is not the expected type, validation failed.")
104
+ obj.achievements.is_a?(Array) != false || raise("Passed value for field obj.achievements is not the expected type, validation failed.")
105
+ obj.leaderboards.is_a?(Hash) != false || raise("Passed value for field obj.leaderboards is not the expected type, validation failed.")
106
+ end
107
+ end
108
+ end