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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2eaf3a319672f092fa93d7ffe2ece952a7985823368161cef8271f07f5af7b57
|
|
4
|
+
data.tar.gz: 4d49f9784188682c249b707cd9192d7d90637fd38b551625b29ee0e5aa33d607
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1af2a8abf9c52a8e5ea7287f14abdc4176d013f4c4e7f52601d9fd823ddd8cc732204996e87592e2d0f9bfad33c4b2813caf180c0def5c876c3649d938c4638f
|
|
7
|
+
data.tar.gz: 31f76b9458bac7cabe5fb9b85e9b1f4d89236f1af8de9ebf54697e4f763be764ce24ebdc25f9af978dbc7f4910a4ca086a462802a04ebeb1e78704c424cc73bb
|
data/lib/gemconfig.rb
CHANGED
|
@@ -6,24 +6,24 @@ require_relative "streaks/client"
|
|
|
6
6
|
module TrophyApiClient
|
|
7
7
|
module Admin
|
|
8
8
|
class Client
|
|
9
|
-
# @return [TrophyApiClient::Admin::
|
|
10
|
-
attr_reader :
|
|
9
|
+
# @return [TrophyApiClient::Admin::StreaksClient]
|
|
10
|
+
attr_reader :streaks
|
|
11
11
|
|
|
12
12
|
# @param request_client [TrophyApiClient::RequestClient]
|
|
13
13
|
# @return [TrophyApiClient::Admin::Client]
|
|
14
14
|
def initialize(request_client:)
|
|
15
|
-
@
|
|
15
|
+
@streaks = TrophyApiClient::Admin::StreaksClient.new(request_client: request_client)
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
class AsyncClient
|
|
20
|
-
# @return [TrophyApiClient::Admin::
|
|
21
|
-
attr_reader :
|
|
20
|
+
# @return [TrophyApiClient::Admin::AsyncStreaksClient]
|
|
21
|
+
attr_reader :streaks
|
|
22
22
|
|
|
23
23
|
# @param request_client [TrophyApiClient::AsyncRequestClient]
|
|
24
24
|
# @return [TrophyApiClient::Admin::AsyncClient]
|
|
25
25
|
def initialize(request_client:)
|
|
26
|
-
@
|
|
26
|
+
@streaks = TrophyApiClient::Admin::AsyncStreaksClient.new(request_client: request_client)
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
end
|
|
@@ -1,30 +1,95 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "../../../requests"
|
|
4
|
-
require_relative "
|
|
4
|
+
require_relative "../../types/restore_streaks_response"
|
|
5
|
+
require "async"
|
|
5
6
|
|
|
6
7
|
module TrophyApiClient
|
|
7
8
|
module Admin
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
attr_reader :freezes
|
|
9
|
+
class StreaksClient
|
|
10
|
+
# @return [TrophyApiClient::RequestClient]
|
|
11
|
+
attr_reader :request_client
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
# @param request_client [TrophyApiClient::RequestClient]
|
|
14
|
+
# @return [TrophyApiClient::Admin::StreaksClient]
|
|
15
|
+
def initialize(request_client:)
|
|
16
|
+
@request_client = request_client
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Restore streaks for multiple users to the maximum length in the last 90 days (in
|
|
20
|
+
# the case of daily streaks), one year (in the case of weekly streaks), or two
|
|
21
|
+
# years (in the case of monthly streaks).
|
|
22
|
+
#
|
|
23
|
+
# @param user_ids [Array<String>] Array of user IDs to restore streaks for. Maximum 100 users per request.
|
|
24
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
25
|
+
# @return [TrophyApiClient::RestoreStreaksResponse]
|
|
26
|
+
# @example
|
|
27
|
+
# api = TrophyApiClient::Client.new(
|
|
28
|
+
# base_url: "https://api.example.com",
|
|
29
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
30
|
+
# api_key: "YOUR_API_KEY"
|
|
31
|
+
# )
|
|
32
|
+
# api.admin.streaks.restore(user_ids: ["user-123", "user-456"])
|
|
33
|
+
def restore(user_ids:, request_options: nil)
|
|
34
|
+
response = @request_client.conn.post do |req|
|
|
35
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
36
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
37
|
+
req.headers = {
|
|
38
|
+
**(req.headers || {}),
|
|
39
|
+
**@request_client.get_headers,
|
|
40
|
+
**(request_options&.additional_headers || {})
|
|
41
|
+
}.compact
|
|
42
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
43
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
44
|
+
end
|
|
45
|
+
req.body = { **(request_options&.additional_body_parameters || {}), userIds: user_ids }.compact
|
|
46
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/streaks/restore"
|
|
17
47
|
end
|
|
48
|
+
TrophyApiClient::RestoreStreaksResponse.from_json(json_object: response.body)
|
|
18
49
|
end
|
|
50
|
+
end
|
|
19
51
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
52
|
+
class AsyncStreaksClient
|
|
53
|
+
# @return [TrophyApiClient::AsyncRequestClient]
|
|
54
|
+
attr_reader :request_client
|
|
55
|
+
|
|
56
|
+
# @param request_client [TrophyApiClient::AsyncRequestClient]
|
|
57
|
+
# @return [TrophyApiClient::Admin::AsyncStreaksClient]
|
|
58
|
+
def initialize(request_client:)
|
|
59
|
+
@request_client = request_client
|
|
60
|
+
end
|
|
23
61
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
62
|
+
# Restore streaks for multiple users to the maximum length in the last 90 days (in
|
|
63
|
+
# the case of daily streaks), one year (in the case of weekly streaks), or two
|
|
64
|
+
# years (in the case of monthly streaks).
|
|
65
|
+
#
|
|
66
|
+
# @param user_ids [Array<String>] Array of user IDs to restore streaks for. Maximum 100 users per request.
|
|
67
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
68
|
+
# @return [TrophyApiClient::RestoreStreaksResponse]
|
|
69
|
+
# @example
|
|
70
|
+
# api = TrophyApiClient::Client.new(
|
|
71
|
+
# base_url: "https://api.example.com",
|
|
72
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
73
|
+
# api_key: "YOUR_API_KEY"
|
|
74
|
+
# )
|
|
75
|
+
# api.admin.streaks.restore(user_ids: ["user-123", "user-456"])
|
|
76
|
+
def restore(user_ids:, request_options: nil)
|
|
77
|
+
Async do
|
|
78
|
+
response = @request_client.conn.post do |req|
|
|
79
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
80
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
81
|
+
req.headers = {
|
|
82
|
+
**(req.headers || {}),
|
|
83
|
+
**@request_client.get_headers,
|
|
84
|
+
**(request_options&.additional_headers || {})
|
|
85
|
+
}.compact
|
|
86
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
87
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
88
|
+
end
|
|
89
|
+
req.body = { **(request_options&.additional_body_parameters || {}), userIds: user_ids }.compact
|
|
90
|
+
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/streaks/restore"
|
|
91
|
+
end
|
|
92
|
+
TrophyApiClient::RestoreStreaksResponse.from_json(json_object: response.body)
|
|
28
93
|
end
|
|
29
94
|
end
|
|
30
95
|
end
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative "metric_event_streak_response"
|
|
4
4
|
require "date"
|
|
5
|
+
require_relative "achievement_with_stats_response_user_attributes_item"
|
|
6
|
+
require_relative "achievement_with_stats_response_event_attribute"
|
|
5
7
|
require_relative "achievement_response_trigger"
|
|
6
8
|
require "ostruct"
|
|
7
9
|
require "json"
|
|
@@ -13,6 +15,16 @@ module TrophyApiClient
|
|
|
13
15
|
# @return [DateTime] The date and time the achievement was completed, in ISO 8601 format. Null if the
|
|
14
16
|
# achievement has not been completed.
|
|
15
17
|
attr_reader :achieved_at
|
|
18
|
+
# @return [Integer] The number of users who have completed this achievement.
|
|
19
|
+
attr_reader :completions
|
|
20
|
+
# @return [Float] The percentage of all users who have completed this achievement.
|
|
21
|
+
attr_reader :rarity
|
|
22
|
+
# @return [Array<TrophyApiClient::AchievementWithStatsResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
|
|
23
|
+
# Only present if the achievement has user attribute filters configured.
|
|
24
|
+
attr_reader :user_attributes
|
|
25
|
+
# @return [TrophyApiClient::AchievementWithStatsResponseEventAttribute] Event attribute filter that must be met for this achievement to be completed.
|
|
26
|
+
# Only present if the achievement has an event filter configured.
|
|
27
|
+
attr_reader :event_attribute
|
|
16
28
|
# @return [String] The unique ID of the achievement.
|
|
17
29
|
attr_reader :id
|
|
18
30
|
# @return [String] The name of this achievement.
|
|
@@ -49,6 +61,12 @@ module TrophyApiClient
|
|
|
49
61
|
# @param current_streak [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
|
50
62
|
# @param achieved_at [DateTime] The date and time the achievement was completed, in ISO 8601 format. Null if the
|
|
51
63
|
# achievement has not been completed.
|
|
64
|
+
# @param completions [Integer] The number of users who have completed this achievement.
|
|
65
|
+
# @param rarity [Float] The percentage of all users who have completed this achievement.
|
|
66
|
+
# @param user_attributes [Array<TrophyApiClient::AchievementWithStatsResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
|
|
67
|
+
# Only present if the achievement has user attribute filters configured.
|
|
68
|
+
# @param event_attribute [TrophyApiClient::AchievementWithStatsResponseEventAttribute] Event attribute filter that must be met for this achievement to be completed.
|
|
69
|
+
# Only present if the achievement has an event filter configured.
|
|
52
70
|
# @param id [String] The unique ID of the achievement.
|
|
53
71
|
# @param name [String] The name of this achievement.
|
|
54
72
|
# @param trigger [TrophyApiClient::AchievementResponseTrigger] The trigger of the achievement.
|
|
@@ -66,10 +84,14 @@ module TrophyApiClient
|
|
|
66
84
|
# trigger = 'metric')
|
|
67
85
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
68
86
|
# @return [TrophyApiClient::AchievementCompletionResponseAchievement]
|
|
69
|
-
def initialize(id:, name:, trigger:, key:, current_streak: OMIT, achieved_at: OMIT,
|
|
70
|
-
badge_url: OMIT, streak_length: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, additional_properties: nil)
|
|
87
|
+
def initialize(completions:, rarity:, id:, name:, trigger:, key:, current_streak: OMIT, achieved_at: OMIT, user_attributes: OMIT,
|
|
88
|
+
event_attribute: OMIT, description: OMIT, badge_url: OMIT, streak_length: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, additional_properties: nil)
|
|
71
89
|
@current_streak = current_streak if current_streak != OMIT
|
|
72
90
|
@achieved_at = achieved_at if achieved_at != OMIT
|
|
91
|
+
@completions = completions
|
|
92
|
+
@rarity = rarity
|
|
93
|
+
@user_attributes = user_attributes if user_attributes != OMIT
|
|
94
|
+
@event_attribute = event_attribute if event_attribute != OMIT
|
|
73
95
|
@id = id
|
|
74
96
|
@name = name
|
|
75
97
|
@trigger = trigger
|
|
@@ -84,6 +106,10 @@ module TrophyApiClient
|
|
|
84
106
|
@_field_set = {
|
|
85
107
|
"currentStreak": current_streak,
|
|
86
108
|
"achievedAt": achieved_at,
|
|
109
|
+
"completions": completions,
|
|
110
|
+
"rarity": rarity,
|
|
111
|
+
"userAttributes": user_attributes,
|
|
112
|
+
"eventAttribute": event_attribute,
|
|
87
113
|
"id": id,
|
|
88
114
|
"name": name,
|
|
89
115
|
"trigger": trigger,
|
|
@@ -114,6 +140,18 @@ module TrophyApiClient
|
|
|
114
140
|
current_streak = TrophyApiClient::MetricEventStreakResponse.from_json(json_object: current_streak)
|
|
115
141
|
end
|
|
116
142
|
achieved_at = (DateTime.parse(parsed_json["achievedAt"]) unless parsed_json["achievedAt"].nil?)
|
|
143
|
+
completions = parsed_json["completions"]
|
|
144
|
+
rarity = parsed_json["rarity"]
|
|
145
|
+
user_attributes = parsed_json["userAttributes"]&.map do |item|
|
|
146
|
+
item = item.to_json
|
|
147
|
+
TrophyApiClient::AchievementWithStatsResponseUserAttributesItem.from_json(json_object: item)
|
|
148
|
+
end
|
|
149
|
+
if parsed_json["eventAttribute"].nil?
|
|
150
|
+
event_attribute = nil
|
|
151
|
+
else
|
|
152
|
+
event_attribute = parsed_json["eventAttribute"].to_json
|
|
153
|
+
event_attribute = TrophyApiClient::AchievementWithStatsResponseEventAttribute.from_json(json_object: event_attribute)
|
|
154
|
+
end
|
|
117
155
|
id = parsed_json["id"]
|
|
118
156
|
name = parsed_json["name"]
|
|
119
157
|
trigger = parsed_json["trigger"]
|
|
@@ -127,6 +165,10 @@ module TrophyApiClient
|
|
|
127
165
|
new(
|
|
128
166
|
current_streak: current_streak,
|
|
129
167
|
achieved_at: achieved_at,
|
|
168
|
+
completions: completions,
|
|
169
|
+
rarity: rarity,
|
|
170
|
+
user_attributes: user_attributes,
|
|
171
|
+
event_attribute: event_attribute,
|
|
130
172
|
id: id,
|
|
131
173
|
name: name,
|
|
132
174
|
trigger: trigger,
|
|
@@ -158,6 +200,10 @@ module TrophyApiClient
|
|
|
158
200
|
def self.validate_raw(obj:)
|
|
159
201
|
obj.current_streak.nil? || TrophyApiClient::MetricEventStreakResponse.validate_raw(obj: obj.current_streak)
|
|
160
202
|
obj.achieved_at&.is_a?(DateTime) != false || raise("Passed value for field obj.achieved_at is not the expected type, validation failed.")
|
|
203
|
+
obj.completions.is_a?(Integer) != false || raise("Passed value for field obj.completions is not the expected type, validation failed.")
|
|
204
|
+
obj.rarity.is_a?(Float) != false || raise("Passed value for field obj.rarity is not the expected type, validation failed.")
|
|
205
|
+
obj.user_attributes&.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.")
|
|
206
|
+
obj.event_attribute.nil? || TrophyApiClient::AchievementWithStatsResponseEventAttribute.validate_raw(obj: obj.event_attribute)
|
|
161
207
|
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
|
162
208
|
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
163
209
|
obj.trigger.is_a?(TrophyApiClient::AchievementResponseTrigger) != false || raise("Passed value for field obj.trigger is not the expected type, validation failed.")
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "date"
|
|
4
|
+
require_relative "achievement_with_stats_response_user_attributes_item"
|
|
5
|
+
require_relative "achievement_with_stats_response_event_attribute"
|
|
4
6
|
require_relative "achievement_response_trigger"
|
|
5
7
|
require "ostruct"
|
|
6
8
|
require "json"
|
|
@@ -10,6 +12,16 @@ module TrophyApiClient
|
|
|
10
12
|
# @return [DateTime] The date and time the achievement was completed, in ISO 8601 format. Null if the
|
|
11
13
|
# achievement has not been completed.
|
|
12
14
|
attr_reader :achieved_at
|
|
15
|
+
# @return [Integer] The number of users who have completed this achievement.
|
|
16
|
+
attr_reader :completions
|
|
17
|
+
# @return [Float] The percentage of all users who have completed this achievement.
|
|
18
|
+
attr_reader :rarity
|
|
19
|
+
# @return [Array<TrophyApiClient::AchievementWithStatsResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
|
|
20
|
+
# Only present if the achievement has user attribute filters configured.
|
|
21
|
+
attr_reader :user_attributes
|
|
22
|
+
# @return [TrophyApiClient::AchievementWithStatsResponseEventAttribute] Event attribute filter that must be met for this achievement to be completed.
|
|
23
|
+
# Only present if the achievement has an event filter configured.
|
|
24
|
+
attr_reader :event_attribute
|
|
13
25
|
# @return [String] The unique ID of the achievement.
|
|
14
26
|
attr_reader :id
|
|
15
27
|
# @return [String] The name of this achievement.
|
|
@@ -45,6 +57,12 @@ module TrophyApiClient
|
|
|
45
57
|
|
|
46
58
|
# @param achieved_at [DateTime] The date and time the achievement was completed, in ISO 8601 format. Null if the
|
|
47
59
|
# achievement has not been completed.
|
|
60
|
+
# @param completions [Integer] The number of users who have completed this achievement.
|
|
61
|
+
# @param rarity [Float] The percentage of all users who have completed this achievement.
|
|
62
|
+
# @param user_attributes [Array<TrophyApiClient::AchievementWithStatsResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
|
|
63
|
+
# Only present if the achievement has user attribute filters configured.
|
|
64
|
+
# @param event_attribute [TrophyApiClient::AchievementWithStatsResponseEventAttribute] Event attribute filter that must be met for this achievement to be completed.
|
|
65
|
+
# Only present if the achievement has an event filter configured.
|
|
48
66
|
# @param id [String] The unique ID of the achievement.
|
|
49
67
|
# @param name [String] The name of this achievement.
|
|
50
68
|
# @param trigger [TrophyApiClient::AchievementResponseTrigger] The trigger of the achievement.
|
|
@@ -62,9 +80,13 @@ module TrophyApiClient
|
|
|
62
80
|
# trigger = 'metric')
|
|
63
81
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
64
82
|
# @return [TrophyApiClient::CompletedAchievementResponse]
|
|
65
|
-
def initialize(id:, name:, trigger:, key:, achieved_at: OMIT,
|
|
66
|
-
streak_length: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, additional_properties: nil)
|
|
83
|
+
def initialize(completions:, rarity:, id:, name:, trigger:, key:, achieved_at: OMIT, user_attributes: OMIT,
|
|
84
|
+
event_attribute: OMIT, description: OMIT, badge_url: OMIT, streak_length: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, additional_properties: nil)
|
|
67
85
|
@achieved_at = achieved_at if achieved_at != OMIT
|
|
86
|
+
@completions = completions
|
|
87
|
+
@rarity = rarity
|
|
88
|
+
@user_attributes = user_attributes if user_attributes != OMIT
|
|
89
|
+
@event_attribute = event_attribute if event_attribute != OMIT
|
|
68
90
|
@id = id
|
|
69
91
|
@name = name
|
|
70
92
|
@trigger = trigger
|
|
@@ -78,6 +100,10 @@ module TrophyApiClient
|
|
|
78
100
|
@additional_properties = additional_properties
|
|
79
101
|
@_field_set = {
|
|
80
102
|
"achievedAt": achieved_at,
|
|
103
|
+
"completions": completions,
|
|
104
|
+
"rarity": rarity,
|
|
105
|
+
"userAttributes": user_attributes,
|
|
106
|
+
"eventAttribute": event_attribute,
|
|
81
107
|
"id": id,
|
|
82
108
|
"name": name,
|
|
83
109
|
"trigger": trigger,
|
|
@@ -101,6 +127,18 @@ module TrophyApiClient
|
|
|
101
127
|
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
102
128
|
parsed_json = JSON.parse(json_object)
|
|
103
129
|
achieved_at = (DateTime.parse(parsed_json["achievedAt"]) unless parsed_json["achievedAt"].nil?)
|
|
130
|
+
completions = parsed_json["completions"]
|
|
131
|
+
rarity = parsed_json["rarity"]
|
|
132
|
+
user_attributes = parsed_json["userAttributes"]&.map do |item|
|
|
133
|
+
item = item.to_json
|
|
134
|
+
TrophyApiClient::AchievementWithStatsResponseUserAttributesItem.from_json(json_object: item)
|
|
135
|
+
end
|
|
136
|
+
if parsed_json["eventAttribute"].nil?
|
|
137
|
+
event_attribute = nil
|
|
138
|
+
else
|
|
139
|
+
event_attribute = parsed_json["eventAttribute"].to_json
|
|
140
|
+
event_attribute = TrophyApiClient::AchievementWithStatsResponseEventAttribute.from_json(json_object: event_attribute)
|
|
141
|
+
end
|
|
104
142
|
id = parsed_json["id"]
|
|
105
143
|
name = parsed_json["name"]
|
|
106
144
|
trigger = parsed_json["trigger"]
|
|
@@ -113,6 +151,10 @@ module TrophyApiClient
|
|
|
113
151
|
metric_name = parsed_json["metricName"]
|
|
114
152
|
new(
|
|
115
153
|
achieved_at: achieved_at,
|
|
154
|
+
completions: completions,
|
|
155
|
+
rarity: rarity,
|
|
156
|
+
user_attributes: user_attributes,
|
|
157
|
+
event_attribute: event_attribute,
|
|
116
158
|
id: id,
|
|
117
159
|
name: name,
|
|
118
160
|
trigger: trigger,
|
|
@@ -142,6 +184,10 @@ module TrophyApiClient
|
|
|
142
184
|
# @return [Void]
|
|
143
185
|
def self.validate_raw(obj:)
|
|
144
186
|
obj.achieved_at&.is_a?(DateTime) != false || raise("Passed value for field obj.achieved_at is not the expected type, validation failed.")
|
|
187
|
+
obj.completions.is_a?(Integer) != false || raise("Passed value for field obj.completions is not the expected type, validation failed.")
|
|
188
|
+
obj.rarity.is_a?(Float) != false || raise("Passed value for field obj.rarity is not the expected type, validation failed.")
|
|
189
|
+
obj.user_attributes&.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.")
|
|
190
|
+
obj.event_attribute.nil? || TrophyApiClient::AchievementWithStatsResponseEventAttribute.validate_raw(obj: obj.event_attribute)
|
|
145
191
|
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
|
146
192
|
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
147
193
|
obj.trigger.is_a?(TrophyApiClient::AchievementResponseTrigger) != false || raise("Passed value for field obj.trigger is not the expected type, validation failed.")
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "bulk_insert_issue"
|
|
4
|
+
require "ostruct"
|
|
5
|
+
require "json"
|
|
6
|
+
|
|
7
|
+
module TrophyApiClient
|
|
8
|
+
# Response containing restored users and any issues encountered.
|
|
9
|
+
class RestoreStreaksResponse
|
|
10
|
+
# @return [Array<String>] Array of user IDs whose streaks were successfully restored.
|
|
11
|
+
attr_reader :restored_users
|
|
12
|
+
# @return [Array<TrophyApiClient::BulkInsertIssue>] Array of issues encountered during streak restoration.
|
|
13
|
+
attr_reader :issues
|
|
14
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
15
|
+
attr_reader :additional_properties
|
|
16
|
+
# @return [Object]
|
|
17
|
+
attr_reader :_field_set
|
|
18
|
+
protected :_field_set
|
|
19
|
+
|
|
20
|
+
OMIT = Object.new
|
|
21
|
+
|
|
22
|
+
# @param restored_users [Array<String>] Array of user IDs whose streaks were successfully restored.
|
|
23
|
+
# @param issues [Array<TrophyApiClient::BulkInsertIssue>] Array of issues encountered during streak restoration.
|
|
24
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
25
|
+
# @return [TrophyApiClient::RestoreStreaksResponse]
|
|
26
|
+
def initialize(restored_users:, issues:, additional_properties: nil)
|
|
27
|
+
@restored_users = restored_users
|
|
28
|
+
@issues = issues
|
|
29
|
+
@additional_properties = additional_properties
|
|
30
|
+
@_field_set = { "restoredUsers": restored_users, "issues": issues }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Deserialize a JSON object to an instance of RestoreStreaksResponse
|
|
34
|
+
#
|
|
35
|
+
# @param json_object [String]
|
|
36
|
+
# @return [TrophyApiClient::RestoreStreaksResponse]
|
|
37
|
+
def self.from_json(json_object:)
|
|
38
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
39
|
+
parsed_json = JSON.parse(json_object)
|
|
40
|
+
restored_users = parsed_json["restoredUsers"]
|
|
41
|
+
issues = parsed_json["issues"]&.map do |item|
|
|
42
|
+
item = item.to_json
|
|
43
|
+
TrophyApiClient::BulkInsertIssue.from_json(json_object: item)
|
|
44
|
+
end
|
|
45
|
+
new(
|
|
46
|
+
restored_users: restored_users,
|
|
47
|
+
issues: issues,
|
|
48
|
+
additional_properties: struct
|
|
49
|
+
)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Serialize an instance of RestoreStreaksResponse to a JSON object
|
|
53
|
+
#
|
|
54
|
+
# @return [String]
|
|
55
|
+
def to_json(*_args)
|
|
56
|
+
@_field_set&.to_json
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
60
|
+
# hash and check each fields type against the current object's property
|
|
61
|
+
# definitions.
|
|
62
|
+
#
|
|
63
|
+
# @param obj [Object]
|
|
64
|
+
# @return [Void]
|
|
65
|
+
def self.validate_raw(obj:)
|
|
66
|
+
obj.restored_users.is_a?(Array) != false || raise("Passed value for field obj.restored_users is not the expected type, validation failed.")
|
|
67
|
+
obj.issues.is_a?(Array) != false || raise("Passed value for field obj.issues is not the expected type, validation failed.")
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "wrapped_most_active_day"
|
|
4
|
+
require_relative "wrapped_most_active_week"
|
|
5
|
+
require_relative "wrapped_most_active_month"
|
|
6
|
+
require_relative "wrapped_entire_year"
|
|
7
|
+
require "ostruct"
|
|
8
|
+
require "json"
|
|
9
|
+
|
|
10
|
+
module TrophyApiClient
|
|
11
|
+
# The user's activity summary for the wrapped year.
|
|
12
|
+
class WrappedActivity
|
|
13
|
+
# @return [Integer] The number of days the user was active during the year.
|
|
14
|
+
attr_reader :days_active
|
|
15
|
+
# @return [Integer] The number of weeks the user was active during the year.
|
|
16
|
+
attr_reader :weeks_active
|
|
17
|
+
# @return [Integer] The number of months the user was active during the year.
|
|
18
|
+
attr_reader :months_active
|
|
19
|
+
# @return [TrophyApiClient::WrappedMostActiveDay] Data about the user's most active day.
|
|
20
|
+
attr_reader :most_active_day
|
|
21
|
+
# @return [TrophyApiClient::WrappedMostActiveWeek] Data about the user's most active week.
|
|
22
|
+
attr_reader :most_active_week
|
|
23
|
+
# @return [TrophyApiClient::WrappedMostActiveMonth] Data about the user's most active month.
|
|
24
|
+
attr_reader :most_active_month
|
|
25
|
+
# @return [TrophyApiClient::WrappedEntireYear] Data about the user's activity for the entire year.
|
|
26
|
+
attr_reader :entire_year
|
|
27
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
28
|
+
attr_reader :additional_properties
|
|
29
|
+
# @return [Object]
|
|
30
|
+
attr_reader :_field_set
|
|
31
|
+
protected :_field_set
|
|
32
|
+
|
|
33
|
+
OMIT = Object.new
|
|
34
|
+
|
|
35
|
+
# @param days_active [Integer] The number of days the user was active during the year.
|
|
36
|
+
# @param weeks_active [Integer] The number of weeks the user was active during the year.
|
|
37
|
+
# @param months_active [Integer] The number of months the user was active during the year.
|
|
38
|
+
# @param most_active_day [TrophyApiClient::WrappedMostActiveDay] Data about the user's most active day.
|
|
39
|
+
# @param most_active_week [TrophyApiClient::WrappedMostActiveWeek] Data about the user's most active week.
|
|
40
|
+
# @param most_active_month [TrophyApiClient::WrappedMostActiveMonth] Data about the user's most active month.
|
|
41
|
+
# @param entire_year [TrophyApiClient::WrappedEntireYear] Data about the user's activity for the entire year.
|
|
42
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
43
|
+
# @return [TrophyApiClient::WrappedActivity]
|
|
44
|
+
def initialize(days_active:, weeks_active:, months_active:, most_active_day:, most_active_week:,
|
|
45
|
+
most_active_month:, entire_year:, additional_properties: nil)
|
|
46
|
+
@days_active = days_active
|
|
47
|
+
@weeks_active = weeks_active
|
|
48
|
+
@months_active = months_active
|
|
49
|
+
@most_active_day = most_active_day
|
|
50
|
+
@most_active_week = most_active_week
|
|
51
|
+
@most_active_month = most_active_month
|
|
52
|
+
@entire_year = entire_year
|
|
53
|
+
@additional_properties = additional_properties
|
|
54
|
+
@_field_set = {
|
|
55
|
+
"daysActive": days_active,
|
|
56
|
+
"weeksActive": weeks_active,
|
|
57
|
+
"monthsActive": months_active,
|
|
58
|
+
"mostActiveDay": most_active_day,
|
|
59
|
+
"mostActiveWeek": most_active_week,
|
|
60
|
+
"mostActiveMonth": most_active_month,
|
|
61
|
+
"entireYear": entire_year
|
|
62
|
+
}
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Deserialize a JSON object to an instance of WrappedActivity
|
|
66
|
+
#
|
|
67
|
+
# @param json_object [String]
|
|
68
|
+
# @return [TrophyApiClient::WrappedActivity]
|
|
69
|
+
def self.from_json(json_object:)
|
|
70
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
71
|
+
parsed_json = JSON.parse(json_object)
|
|
72
|
+
days_active = parsed_json["daysActive"]
|
|
73
|
+
weeks_active = parsed_json["weeksActive"]
|
|
74
|
+
months_active = parsed_json["monthsActive"]
|
|
75
|
+
if parsed_json["mostActiveDay"].nil?
|
|
76
|
+
most_active_day = nil
|
|
77
|
+
else
|
|
78
|
+
most_active_day = parsed_json["mostActiveDay"].to_json
|
|
79
|
+
most_active_day = TrophyApiClient::WrappedMostActiveDay.from_json(json_object: most_active_day)
|
|
80
|
+
end
|
|
81
|
+
if parsed_json["mostActiveWeek"].nil?
|
|
82
|
+
most_active_week = nil
|
|
83
|
+
else
|
|
84
|
+
most_active_week = parsed_json["mostActiveWeek"].to_json
|
|
85
|
+
most_active_week = TrophyApiClient::WrappedMostActiveWeek.from_json(json_object: most_active_week)
|
|
86
|
+
end
|
|
87
|
+
if parsed_json["mostActiveMonth"].nil?
|
|
88
|
+
most_active_month = nil
|
|
89
|
+
else
|
|
90
|
+
most_active_month = parsed_json["mostActiveMonth"].to_json
|
|
91
|
+
most_active_month = TrophyApiClient::WrappedMostActiveMonth.from_json(json_object: most_active_month)
|
|
92
|
+
end
|
|
93
|
+
if parsed_json["entireYear"].nil?
|
|
94
|
+
entire_year = nil
|
|
95
|
+
else
|
|
96
|
+
entire_year = parsed_json["entireYear"].to_json
|
|
97
|
+
entire_year = TrophyApiClient::WrappedEntireYear.from_json(json_object: entire_year)
|
|
98
|
+
end
|
|
99
|
+
new(
|
|
100
|
+
days_active: days_active,
|
|
101
|
+
weeks_active: weeks_active,
|
|
102
|
+
months_active: months_active,
|
|
103
|
+
most_active_day: most_active_day,
|
|
104
|
+
most_active_week: most_active_week,
|
|
105
|
+
most_active_month: most_active_month,
|
|
106
|
+
entire_year: entire_year,
|
|
107
|
+
additional_properties: struct
|
|
108
|
+
)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Serialize an instance of WrappedActivity to a JSON object
|
|
112
|
+
#
|
|
113
|
+
# @return [String]
|
|
114
|
+
def to_json(*_args)
|
|
115
|
+
@_field_set&.to_json
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
119
|
+
# hash and check each fields type against the current object's property
|
|
120
|
+
# definitions.
|
|
121
|
+
#
|
|
122
|
+
# @param obj [Object]
|
|
123
|
+
# @return [Void]
|
|
124
|
+
def self.validate_raw(obj:)
|
|
125
|
+
obj.days_active.is_a?(Integer) != false || raise("Passed value for field obj.days_active is not the expected type, validation failed.")
|
|
126
|
+
obj.weeks_active.is_a?(Integer) != false || raise("Passed value for field obj.weeks_active is not the expected type, validation failed.")
|
|
127
|
+
obj.months_active.is_a?(Integer) != false || raise("Passed value for field obj.months_active is not the expected type, validation failed.")
|
|
128
|
+
TrophyApiClient::WrappedMostActiveDay.validate_raw(obj: obj.most_active_day)
|
|
129
|
+
TrophyApiClient::WrappedMostActiveWeek.validate_raw(obj: obj.most_active_week)
|
|
130
|
+
TrophyApiClient::WrappedMostActiveMonth.validate_raw(obj: obj.most_active_month)
|
|
131
|
+
TrophyApiClient::WrappedEntireYear.validate_raw(obj: obj.entire_year)
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|