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.
- checksums.yaml +4 -4
- data/lib/gemconfig.rb +1 -1
- data/lib/trophy_api_client/admin/client.rb +6 -6
- data/lib/trophy_api_client/admin/streaks/client.rb +81 -16
- data/lib/trophy_api_client/types/achievement_completion_response_achievement.rb +48 -2
- data/lib/trophy_api_client/types/completed_achievement_response.rb +48 -2
- data/lib/trophy_api_client/types/restore_streaks_response.rb +70 -0
- data/lib/trophy_api_client/types/wrapped_activity.rb +134 -0
- data/lib/trophy_api_client/types/wrapped_activity_period.rb +95 -0
- data/lib/trophy_api_client/types/wrapped_entire_year.rb +114 -0
- data/lib/trophy_api_client/types/wrapped_metric.rb +119 -0
- data/lib/trophy_api_client/types/wrapped_metric_by_attribute_value_value.rb +103 -0
- data/lib/trophy_api_client/types/wrapped_most_active_day.rb +108 -0
- data/lib/trophy_api_client/types/wrapped_most_active_month.rb +108 -0
- data/lib/trophy_api_client/types/wrapped_most_active_week.rb +116 -0
- data/lib/trophy_api_client/types/wrapped_points.rb +106 -0
- data/lib/trophy_api_client/types/wrapped_response.rb +79 -0
- data/lib/trophy_api_client/types/wrapped_streak.rb +96 -0
- data/lib/trophy_api_client/users/client.rb +67 -0
- data/lib/trophy_api_client/version.rb +1 -1
- data/lib/types_export.rb +12 -0
- metadata +13 -1
|
@@ -0,0 +1,116 @@
|
|
|
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 week during the year.
|
|
9
|
+
class WrappedMostActiveWeek
|
|
10
|
+
# @return [String] The start date of the most active week in YYYY-MM-DD format.
|
|
11
|
+
attr_reader :start
|
|
12
|
+
# @return [String] The end date of the most active week in YYYY-MM-DD format.
|
|
13
|
+
attr_reader :end_
|
|
14
|
+
# @return [Hash{String => TrophyApiClient::WrappedMetric}] The user's metrics during this period, keyed by metric key.
|
|
15
|
+
attr_reader :metrics
|
|
16
|
+
# @return [Hash{String => TrophyApiClient::WrappedPoints}] The user's points during this period, keyed by points system key.
|
|
17
|
+
attr_reader :points
|
|
18
|
+
# @return [Array<TrophyApiClient::CompletedAchievementResponse>] Achievements completed during this period.
|
|
19
|
+
attr_reader :achievements
|
|
20
|
+
# @return [Hash{String => TrophyApiClient::UserLeaderboardResponse}] The user's best leaderboard rankings during this period, keyed by leaderboard
|
|
21
|
+
# key.
|
|
22
|
+
attr_reader :leaderboards
|
|
23
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
24
|
+
attr_reader :additional_properties
|
|
25
|
+
# @return [Object]
|
|
26
|
+
attr_reader :_field_set
|
|
27
|
+
protected :_field_set
|
|
28
|
+
|
|
29
|
+
OMIT = Object.new
|
|
30
|
+
|
|
31
|
+
# @param start [String] The start date of the most active week in YYYY-MM-DD format.
|
|
32
|
+
# @param end_ [String] The end date of the most active week in YYYY-MM-DD format.
|
|
33
|
+
# @param metrics [Hash{String => TrophyApiClient::WrappedMetric}] The user's metrics during this period, keyed by metric key.
|
|
34
|
+
# @param points [Hash{String => TrophyApiClient::WrappedPoints}] The user's points during this period, keyed by points system key.
|
|
35
|
+
# @param achievements [Array<TrophyApiClient::CompletedAchievementResponse>] Achievements completed during this period.
|
|
36
|
+
# @param leaderboards [Hash{String => TrophyApiClient::UserLeaderboardResponse}] The user's best leaderboard rankings during this period, keyed by leaderboard
|
|
37
|
+
# key.
|
|
38
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
39
|
+
# @return [TrophyApiClient::WrappedMostActiveWeek]
|
|
40
|
+
def initialize(start:, end_:, metrics:, points:, achievements:, leaderboards:, additional_properties: nil)
|
|
41
|
+
@start = start
|
|
42
|
+
@end_ = end_
|
|
43
|
+
@metrics = metrics
|
|
44
|
+
@points = points
|
|
45
|
+
@achievements = achievements
|
|
46
|
+
@leaderboards = leaderboards
|
|
47
|
+
@additional_properties = additional_properties
|
|
48
|
+
@_field_set = {
|
|
49
|
+
"start": start,
|
|
50
|
+
"end": end_,
|
|
51
|
+
"metrics": metrics,
|
|
52
|
+
"points": points,
|
|
53
|
+
"achievements": achievements,
|
|
54
|
+
"leaderboards": leaderboards
|
|
55
|
+
}
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Deserialize a JSON object to an instance of WrappedMostActiveWeek
|
|
59
|
+
#
|
|
60
|
+
# @param json_object [String]
|
|
61
|
+
# @return [TrophyApiClient::WrappedMostActiveWeek]
|
|
62
|
+
def self.from_json(json_object:)
|
|
63
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
64
|
+
parsed_json = JSON.parse(json_object)
|
|
65
|
+
start = parsed_json["start"]
|
|
66
|
+
end_ = parsed_json["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
|
+
start: start,
|
|
85
|
+
end_: end_,
|
|
86
|
+
metrics: metrics,
|
|
87
|
+
points: points,
|
|
88
|
+
achievements: achievements,
|
|
89
|
+
leaderboards: leaderboards,
|
|
90
|
+
additional_properties: struct
|
|
91
|
+
)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Serialize an instance of WrappedMostActiveWeek to a JSON object
|
|
95
|
+
#
|
|
96
|
+
# @return [String]
|
|
97
|
+
def to_json(*_args)
|
|
98
|
+
@_field_set&.to_json
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
102
|
+
# hash and check each fields type against the current object's property
|
|
103
|
+
# definitions.
|
|
104
|
+
#
|
|
105
|
+
# @param obj [Object]
|
|
106
|
+
# @return [Void]
|
|
107
|
+
def self.validate_raw(obj:)
|
|
108
|
+
obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
|
|
109
|
+
obj.end_.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
|
|
110
|
+
obj.metrics.is_a?(Hash) != false || raise("Passed value for field obj.metrics is not the expected type, validation failed.")
|
|
111
|
+
obj.points.is_a?(Hash) != false || raise("Passed value for field obj.points is not the expected type, validation failed.")
|
|
112
|
+
obj.achievements.is_a?(Array) != false || raise("Passed value for field obj.achievements is not the expected type, validation failed.")
|
|
113
|
+
obj.leaderboards.is_a?(Hash) != false || raise("Passed value for field obj.leaderboards is not the expected type, validation failed.")
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "ostruct"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module TrophyApiClient
|
|
7
|
+
# A user's points data for a wrapped period.
|
|
8
|
+
class WrappedPoints
|
|
9
|
+
# @return [String] The name of the points system.
|
|
10
|
+
attr_reader :name
|
|
11
|
+
# @return [String] The description of the points system.
|
|
12
|
+
attr_reader :description
|
|
13
|
+
# @return [Float] The user's current total points.
|
|
14
|
+
attr_reader :current_total
|
|
15
|
+
# @return [Float] The change in points during the period.
|
|
16
|
+
attr_reader :change_this_period
|
|
17
|
+
# @return [Float] The percentage change in points during the period.
|
|
18
|
+
attr_reader :percent_change
|
|
19
|
+
# @return [Float] The user's percentile rank for this points system during the period. Only
|
|
20
|
+
# included for weekly, monthly, and yearly aggregation periods.
|
|
21
|
+
attr_reader :percentile_this_period
|
|
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 name [String] The name of the points system.
|
|
31
|
+
# @param description [String] The description of the points system.
|
|
32
|
+
# @param current_total [Float] The user's current total points.
|
|
33
|
+
# @param change_this_period [Float] The change in points during the period.
|
|
34
|
+
# @param percent_change [Float] The percentage change in points during the period.
|
|
35
|
+
# @param percentile_this_period [Float] The user's percentile rank for this points system during the period. Only
|
|
36
|
+
# included for weekly, monthly, and yearly aggregation periods.
|
|
37
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
38
|
+
# @return [TrophyApiClient::WrappedPoints]
|
|
39
|
+
def initialize(name:, current_total:, change_this_period:, percent_change:, description: OMIT,
|
|
40
|
+
percentile_this_period: OMIT, additional_properties: nil)
|
|
41
|
+
@name = name
|
|
42
|
+
@description = description if description != OMIT
|
|
43
|
+
@current_total = current_total
|
|
44
|
+
@change_this_period = change_this_period
|
|
45
|
+
@percent_change = percent_change
|
|
46
|
+
@percentile_this_period = percentile_this_period if percentile_this_period != OMIT
|
|
47
|
+
@additional_properties = additional_properties
|
|
48
|
+
@_field_set = {
|
|
49
|
+
"name": name,
|
|
50
|
+
"description": description,
|
|
51
|
+
"currentTotal": current_total,
|
|
52
|
+
"changeThisPeriod": change_this_period,
|
|
53
|
+
"percentChange": percent_change,
|
|
54
|
+
"percentileThisPeriod": percentile_this_period
|
|
55
|
+
}.reject do |_k, v|
|
|
56
|
+
v == OMIT
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Deserialize a JSON object to an instance of WrappedPoints
|
|
61
|
+
#
|
|
62
|
+
# @param json_object [String]
|
|
63
|
+
# @return [TrophyApiClient::WrappedPoints]
|
|
64
|
+
def self.from_json(json_object:)
|
|
65
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
66
|
+
parsed_json = JSON.parse(json_object)
|
|
67
|
+
name = parsed_json["name"]
|
|
68
|
+
description = parsed_json["description"]
|
|
69
|
+
current_total = parsed_json["currentTotal"]
|
|
70
|
+
change_this_period = parsed_json["changeThisPeriod"]
|
|
71
|
+
percent_change = parsed_json["percentChange"]
|
|
72
|
+
percentile_this_period = parsed_json["percentileThisPeriod"]
|
|
73
|
+
new(
|
|
74
|
+
name: name,
|
|
75
|
+
description: description,
|
|
76
|
+
current_total: current_total,
|
|
77
|
+
change_this_period: change_this_period,
|
|
78
|
+
percent_change: percent_change,
|
|
79
|
+
percentile_this_period: percentile_this_period,
|
|
80
|
+
additional_properties: struct
|
|
81
|
+
)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Serialize an instance of WrappedPoints to a JSON object
|
|
85
|
+
#
|
|
86
|
+
# @return [String]
|
|
87
|
+
def to_json(*_args)
|
|
88
|
+
@_field_set&.to_json
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
92
|
+
# hash and check each fields type against the current object's property
|
|
93
|
+
# definitions.
|
|
94
|
+
#
|
|
95
|
+
# @param obj [Object]
|
|
96
|
+
# @return [Void]
|
|
97
|
+
def self.validate_raw(obj:)
|
|
98
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
99
|
+
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
|
100
|
+
obj.current_total.is_a?(Float) != false || raise("Passed value for field obj.current_total is not the expected type, validation failed.")
|
|
101
|
+
obj.change_this_period.is_a?(Float) != false || raise("Passed value for field obj.change_this_period is not the expected type, validation failed.")
|
|
102
|
+
obj.percent_change.is_a?(Float) != false || raise("Passed value for field obj.percent_change is not the expected type, validation failed.")
|
|
103
|
+
obj.percentile_this_period&.is_a?(Float) != false || raise("Passed value for field obj.percentile_this_period is not the expected type, validation failed.")
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "user"
|
|
4
|
+
require_relative "wrapped_activity"
|
|
5
|
+
require "ostruct"
|
|
6
|
+
require "json"
|
|
7
|
+
|
|
8
|
+
module TrophyApiClient
|
|
9
|
+
# A user's year-in-review wrapped data including activity summaries, metrics,
|
|
10
|
+
# points, achievements, streaks, and leaderboard rankings.
|
|
11
|
+
class WrappedResponse
|
|
12
|
+
# @return [TrophyApiClient::User] The user's profile information.
|
|
13
|
+
attr_reader :user
|
|
14
|
+
# @return [TrophyApiClient::WrappedActivity] The user's activity data for the wrapped year.
|
|
15
|
+
attr_reader :activity
|
|
16
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
17
|
+
attr_reader :additional_properties
|
|
18
|
+
# @return [Object]
|
|
19
|
+
attr_reader :_field_set
|
|
20
|
+
protected :_field_set
|
|
21
|
+
|
|
22
|
+
OMIT = Object.new
|
|
23
|
+
|
|
24
|
+
# @param user [TrophyApiClient::User] The user's profile information.
|
|
25
|
+
# @param activity [TrophyApiClient::WrappedActivity] The user's activity data for the wrapped year.
|
|
26
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
27
|
+
# @return [TrophyApiClient::WrappedResponse]
|
|
28
|
+
def initialize(user:, activity:, additional_properties: nil)
|
|
29
|
+
@user = user
|
|
30
|
+
@activity = activity
|
|
31
|
+
@additional_properties = additional_properties
|
|
32
|
+
@_field_set = { "user": user, "activity": activity }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Deserialize a JSON object to an instance of WrappedResponse
|
|
36
|
+
#
|
|
37
|
+
# @param json_object [String]
|
|
38
|
+
# @return [TrophyApiClient::WrappedResponse]
|
|
39
|
+
def self.from_json(json_object:)
|
|
40
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
41
|
+
parsed_json = JSON.parse(json_object)
|
|
42
|
+
if parsed_json["user"].nil?
|
|
43
|
+
user = nil
|
|
44
|
+
else
|
|
45
|
+
user = parsed_json["user"].to_json
|
|
46
|
+
user = TrophyApiClient::User.from_json(json_object: user)
|
|
47
|
+
end
|
|
48
|
+
if parsed_json["activity"].nil?
|
|
49
|
+
activity = nil
|
|
50
|
+
else
|
|
51
|
+
activity = parsed_json["activity"].to_json
|
|
52
|
+
activity = TrophyApiClient::WrappedActivity.from_json(json_object: activity)
|
|
53
|
+
end
|
|
54
|
+
new(
|
|
55
|
+
user: user,
|
|
56
|
+
activity: activity,
|
|
57
|
+
additional_properties: struct
|
|
58
|
+
)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Serialize an instance of WrappedResponse to a JSON object
|
|
62
|
+
#
|
|
63
|
+
# @return [String]
|
|
64
|
+
def to_json(*_args)
|
|
65
|
+
@_field_set&.to_json
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
69
|
+
# hash and check each fields type against the current object's property
|
|
70
|
+
# definitions.
|
|
71
|
+
#
|
|
72
|
+
# @param obj [Object]
|
|
73
|
+
# @return [Void]
|
|
74
|
+
def self.validate_raw(obj:)
|
|
75
|
+
TrophyApiClient::User.validate_raw(obj: obj.user)
|
|
76
|
+
TrophyApiClient::WrappedActivity.validate_raw(obj: obj.activity)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "streak_frequency"
|
|
4
|
+
require "ostruct"
|
|
5
|
+
require "json"
|
|
6
|
+
|
|
7
|
+
module TrophyApiClient
|
|
8
|
+
# The user's longest streak during the wrapped period.
|
|
9
|
+
class WrappedStreak
|
|
10
|
+
# @return [Integer] The length of the streak.
|
|
11
|
+
attr_reader :length
|
|
12
|
+
# @return [TrophyApiClient::StreakFrequency] The frequency of the streak.
|
|
13
|
+
attr_reader :frequency
|
|
14
|
+
# @return [String] The start date of the streak period.
|
|
15
|
+
attr_reader :period_start
|
|
16
|
+
# @return [String] The end date of the streak period.
|
|
17
|
+
attr_reader :period_end
|
|
18
|
+
# @return [String] The date the streak started.
|
|
19
|
+
attr_reader :started
|
|
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 length [Integer] The length of the streak.
|
|
29
|
+
# @param frequency [TrophyApiClient::StreakFrequency] The frequency of the streak.
|
|
30
|
+
# @param period_start [String] The start date of the streak period.
|
|
31
|
+
# @param period_end [String] The end date of the streak period.
|
|
32
|
+
# @param started [String] The date the streak started.
|
|
33
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
34
|
+
# @return [TrophyApiClient::WrappedStreak]
|
|
35
|
+
def initialize(length:, frequency:, period_start: OMIT, period_end: OMIT, started: OMIT, additional_properties: nil)
|
|
36
|
+
@length = length
|
|
37
|
+
@frequency = frequency
|
|
38
|
+
@period_start = period_start if period_start != OMIT
|
|
39
|
+
@period_end = period_end if period_end != OMIT
|
|
40
|
+
@started = started if started != OMIT
|
|
41
|
+
@additional_properties = additional_properties
|
|
42
|
+
@_field_set = {
|
|
43
|
+
"length": length,
|
|
44
|
+
"frequency": frequency,
|
|
45
|
+
"periodStart": period_start,
|
|
46
|
+
"periodEnd": period_end,
|
|
47
|
+
"started": started
|
|
48
|
+
}.reject do |_k, v|
|
|
49
|
+
v == OMIT
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Deserialize a JSON object to an instance of WrappedStreak
|
|
54
|
+
#
|
|
55
|
+
# @param json_object [String]
|
|
56
|
+
# @return [TrophyApiClient::WrappedStreak]
|
|
57
|
+
def self.from_json(json_object:)
|
|
58
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
59
|
+
parsed_json = JSON.parse(json_object)
|
|
60
|
+
length = parsed_json["length"]
|
|
61
|
+
frequency = parsed_json["frequency"]
|
|
62
|
+
period_start = parsed_json["periodStart"]
|
|
63
|
+
period_end = parsed_json["periodEnd"]
|
|
64
|
+
started = parsed_json["started"]
|
|
65
|
+
new(
|
|
66
|
+
length: length,
|
|
67
|
+
frequency: frequency,
|
|
68
|
+
period_start: period_start,
|
|
69
|
+
period_end: period_end,
|
|
70
|
+
started: started,
|
|
71
|
+
additional_properties: struct
|
|
72
|
+
)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Serialize an instance of WrappedStreak 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.length.is_a?(Integer) != false || raise("Passed value for field obj.length is not the expected type, validation failed.")
|
|
90
|
+
obj.frequency.is_a?(TrophyApiClient::StreakFrequency) != false || raise("Passed value for field obj.frequency is not the expected type, validation failed.")
|
|
91
|
+
obj.period_start&.is_a?(String) != false || raise("Passed value for field obj.period_start is not the expected type, validation failed.")
|
|
92
|
+
obj.period_end&.is_a?(String) != false || raise("Passed value for field obj.period_end is not the expected type, validation failed.")
|
|
93
|
+
obj.started&.is_a?(String) != false || raise("Passed value for field obj.started is not the expected type, validation failed.")
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -14,6 +14,7 @@ require_relative "../types/get_user_points_response"
|
|
|
14
14
|
require_relative "types/users_points_event_summary_request_aggregation"
|
|
15
15
|
require_relative "types/users_points_event_summary_response_item"
|
|
16
16
|
require_relative "../types/user_leaderboard_response_with_history"
|
|
17
|
+
require_relative "../types/wrapped_response"
|
|
17
18
|
require "async"
|
|
18
19
|
|
|
19
20
|
module TrophyApiClient
|
|
@@ -501,6 +502,38 @@ module TrophyApiClient
|
|
|
501
502
|
end
|
|
502
503
|
TrophyApiClient::UserLeaderboardResponseWithHistory.from_json(json_object: response.body)
|
|
503
504
|
end
|
|
505
|
+
|
|
506
|
+
# Get a user's year-in-review wrapped data.
|
|
507
|
+
#
|
|
508
|
+
# @param id [String] The user's ID in your database.
|
|
509
|
+
# @param year [Integer] The year to get wrapped data for. Defaults to the current year. Must be an
|
|
510
|
+
# integer between 1 and the current year.
|
|
511
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
512
|
+
# @return [TrophyApiClient::WrappedResponse]
|
|
513
|
+
# @example
|
|
514
|
+
# api = TrophyApiClient::Client.new(
|
|
515
|
+
# base_url: "https://api.example.com",
|
|
516
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
517
|
+
# api_key: "YOUR_API_KEY"
|
|
518
|
+
# )
|
|
519
|
+
# api.users.wrapped(id: "user-123", year: 1)
|
|
520
|
+
def wrapped(id:, year: nil, request_options: nil)
|
|
521
|
+
response = @request_client.conn.get do |req|
|
|
522
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
523
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
524
|
+
req.headers = {
|
|
525
|
+
**(req.headers || {}),
|
|
526
|
+
**@request_client.get_headers,
|
|
527
|
+
**(request_options&.additional_headers || {})
|
|
528
|
+
}.compact
|
|
529
|
+
req.params = { **(request_options&.additional_query_parameters || {}), "year": year }.compact
|
|
530
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
531
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
532
|
+
end
|
|
533
|
+
req.url "#{@request_client.get_url(environment: api, request_options: request_options)}/users/#{id}/wrapped"
|
|
534
|
+
end
|
|
535
|
+
TrophyApiClient::WrappedResponse.from_json(json_object: response.body)
|
|
536
|
+
end
|
|
504
537
|
end
|
|
505
538
|
|
|
506
539
|
class AsyncUsersClient
|
|
@@ -1011,5 +1044,39 @@ module TrophyApiClient
|
|
|
1011
1044
|
TrophyApiClient::UserLeaderboardResponseWithHistory.from_json(json_object: response.body)
|
|
1012
1045
|
end
|
|
1013
1046
|
end
|
|
1047
|
+
|
|
1048
|
+
# Get a user's year-in-review wrapped data.
|
|
1049
|
+
#
|
|
1050
|
+
# @param id [String] The user's ID in your database.
|
|
1051
|
+
# @param year [Integer] The year to get wrapped data for. Defaults to the current year. Must be an
|
|
1052
|
+
# integer between 1 and the current year.
|
|
1053
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
1054
|
+
# @return [TrophyApiClient::WrappedResponse]
|
|
1055
|
+
# @example
|
|
1056
|
+
# api = TrophyApiClient::Client.new(
|
|
1057
|
+
# base_url: "https://api.example.com",
|
|
1058
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
1059
|
+
# api_key: "YOUR_API_KEY"
|
|
1060
|
+
# )
|
|
1061
|
+
# api.users.wrapped(id: "user-123", year: 1)
|
|
1062
|
+
def wrapped(id:, year: nil, request_options: nil)
|
|
1063
|
+
Async do
|
|
1064
|
+
response = @request_client.conn.get do |req|
|
|
1065
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
1066
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
1067
|
+
req.headers = {
|
|
1068
|
+
**(req.headers || {}),
|
|
1069
|
+
**@request_client.get_headers,
|
|
1070
|
+
**(request_options&.additional_headers || {})
|
|
1071
|
+
}.compact
|
|
1072
|
+
req.params = { **(request_options&.additional_query_parameters || {}), "year": year }.compact
|
|
1073
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
1074
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
1075
|
+
end
|
|
1076
|
+
req.url "#{@request_client.get_url(environment: api, request_options: request_options)}/users/#{id}/wrapped"
|
|
1077
|
+
end
|
|
1078
|
+
TrophyApiClient::WrappedResponse.from_json(json_object: response.body)
|
|
1079
|
+
end
|
|
1080
|
+
end
|
|
1014
1081
|
end
|
|
1015
1082
|
end
|
data/lib/types_export.rb
CHANGED
|
@@ -69,5 +69,17 @@ require_relative "trophy_api_client/types/user_leaderboard_response"
|
|
|
69
69
|
require_relative "trophy_api_client/types/user_leaderboard_response_with_history"
|
|
70
70
|
require_relative "trophy_api_client/types/webhook_user_leaderboard_response"
|
|
71
71
|
require_relative "trophy_api_client/types/create_streak_freezes_response"
|
|
72
|
+
require_relative "trophy_api_client/types/restore_streaks_response"
|
|
72
73
|
require_relative "trophy_api_client/types/bulk_insert_issue_level"
|
|
73
74
|
require_relative "trophy_api_client/types/bulk_insert_issue"
|
|
75
|
+
require_relative "trophy_api_client/types/wrapped_metric_by_attribute_value_value"
|
|
76
|
+
require_relative "trophy_api_client/types/wrapped_metric"
|
|
77
|
+
require_relative "trophy_api_client/types/wrapped_points"
|
|
78
|
+
require_relative "trophy_api_client/types/wrapped_streak"
|
|
79
|
+
require_relative "trophy_api_client/types/wrapped_activity_period"
|
|
80
|
+
require_relative "trophy_api_client/types/wrapped_most_active_day"
|
|
81
|
+
require_relative "trophy_api_client/types/wrapped_most_active_week"
|
|
82
|
+
require_relative "trophy_api_client/types/wrapped_most_active_month"
|
|
83
|
+
require_relative "trophy_api_client/types/wrapped_entire_year"
|
|
84
|
+
require_relative "trophy_api_client/types/wrapped_activity"
|
|
85
|
+
require_relative "trophy_api_client/types/wrapped_response"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: trophy_api_client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.38
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Trophy Labs, Inc
|
|
@@ -153,6 +153,7 @@ files:
|
|
|
153
153
|
- lib/trophy_api_client/types/points_trigger_response_user_attributes_item.rb
|
|
154
154
|
- lib/trophy_api_client/types/points_trigger_time_unit.rb
|
|
155
155
|
- lib/trophy_api_client/types/points_trigger_type.rb
|
|
156
|
+
- lib/trophy_api_client/types/restore_streaks_response.rb
|
|
156
157
|
- lib/trophy_api_client/types/streak_frequency.rb
|
|
157
158
|
- lib/trophy_api_client/types/streak_ranking_user.rb
|
|
158
159
|
- lib/trophy_api_client/types/streak_response.rb
|
|
@@ -174,6 +175,17 @@ files:
|
|
|
174
175
|
- lib/trophy_api_client/types/webhooks_streak_freeze_earned_payload.rb
|
|
175
176
|
- lib/trophy_api_client/types/webhooks_streak_lost_payload.rb
|
|
176
177
|
- lib/trophy_api_client/types/webhooks_streak_started_payload.rb
|
|
178
|
+
- lib/trophy_api_client/types/wrapped_activity.rb
|
|
179
|
+
- lib/trophy_api_client/types/wrapped_activity_period.rb
|
|
180
|
+
- lib/trophy_api_client/types/wrapped_entire_year.rb
|
|
181
|
+
- lib/trophy_api_client/types/wrapped_metric.rb
|
|
182
|
+
- lib/trophy_api_client/types/wrapped_metric_by_attribute_value_value.rb
|
|
183
|
+
- lib/trophy_api_client/types/wrapped_most_active_day.rb
|
|
184
|
+
- lib/trophy_api_client/types/wrapped_most_active_month.rb
|
|
185
|
+
- lib/trophy_api_client/types/wrapped_most_active_week.rb
|
|
186
|
+
- lib/trophy_api_client/types/wrapped_points.rb
|
|
187
|
+
- lib/trophy_api_client/types/wrapped_response.rb
|
|
188
|
+
- lib/trophy_api_client/types/wrapped_streak.rb
|
|
177
189
|
- lib/trophy_api_client/users/client.rb
|
|
178
190
|
- lib/trophy_api_client/users/types/users_metric_event_summary_request_aggregation.rb
|
|
179
191
|
- lib/trophy_api_client/users/types/users_metric_event_summary_response_item.rb
|