trophy_api_client 1.0.38 → 1.0.40
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/streaks/client.rb +11 -8
- data/lib/trophy_api_client/admin/streaks/types/restore_streaks_request_users_item.rb +59 -0
- data/lib/trophy_api_client/types/achievement_completion_response.rb +5 -5
- data/lib/trophy_api_client/types/achievement_response.rb +35 -5
- data/lib/trophy_api_client/types/{achievement_with_stats_response_event_attribute.rb → achievement_response_event_attribute.rb} +5 -7
- data/lib/trophy_api_client/types/{achievement_with_stats_response_user_attributes_item.rb → achievement_response_user_attributes_item.rb} +5 -6
- data/lib/trophy_api_client/types/achievement_with_stats_response.rb +35 -35
- data/lib/trophy_api_client/types/bulk_streak_response_item.rb +10 -6
- data/lib/trophy_api_client/types/event_response.rb +4 -4
- data/lib/trophy_api_client/types/metric_response.rb +4 -4
- data/lib/trophy_api_client/types/user.rb +4 -4
- data/lib/trophy_api_client/types/{achievement_completion_response_achievement.rb → user_achievement_response.rb} +40 -72
- data/lib/trophy_api_client/types/{completed_achievement_response.rb → user_achievement_with_stats_response.rb} +40 -40
- data/lib/trophy_api_client/types/webhooks_achievement_completed_payload.rb +5 -5
- data/lib/trophy_api_client/types/wrapped_activity_period.rb +4 -4
- data/lib/trophy_api_client/types/wrapped_entire_year.rb +4 -4
- data/lib/trophy_api_client/types/wrapped_most_active_day.rb +4 -4
- data/lib/trophy_api_client/types/wrapped_most_active_month.rb +4 -4
- data/lib/trophy_api_client/types/wrapped_most_active_week.rb +4 -4
- data/lib/trophy_api_client/users/client.rb +5 -5
- data/lib/trophy_api_client/version.rb +1 -1
- data/lib/types_export.rb +5 -4
- metadata +6 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ccada1b1f574255085097fba1ef98806380bead4795e66a98db917bf82391e4b
|
|
4
|
+
data.tar.gz: c27e60901c8bb55bba1b03b62fac00e247bebdbb16bbd64e9049e27cb7a36cab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d8b112fe94fffcf2c31241bcc91279d184d55dd9b95c0ab10f82d3c122ce60b1427b324f76eb895c9b3f3ef00e9a0b8325f8a0f915ea98eaa1e160180e83d1ae
|
|
7
|
+
data.tar.gz: 28e86210d2381bf56dfba0c43822085ed6042aa955c2bf462147ef097cf0fe9f852ea99d11bbdbe9a0f0fd5618b3179ba6b3d70eb993d673b735424670a6188e
|
data/lib/gemconfig.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "../../../requests"
|
|
4
|
+
require_relative "types/restore_streaks_request_users_item"
|
|
4
5
|
require_relative "../../types/restore_streaks_response"
|
|
5
6
|
require "async"
|
|
6
7
|
|
|
@@ -20,7 +21,8 @@ module TrophyApiClient
|
|
|
20
21
|
# the case of daily streaks), one year (in the case of weekly streaks), or two
|
|
21
22
|
# years (in the case of monthly streaks).
|
|
22
23
|
#
|
|
23
|
-
# @param
|
|
24
|
+
# @param users [Array<Hash>] Array of users to restore streaks for. Maximum 100 users per request.Request of type Array<TrophyApiClient::Admin::Streaks::RestoreStreaksRequestUsersItem>, as a Hash
|
|
25
|
+
# * :id (String)
|
|
24
26
|
# @param request_options [TrophyApiClient::RequestOptions]
|
|
25
27
|
# @return [TrophyApiClient::RestoreStreaksResponse]
|
|
26
28
|
# @example
|
|
@@ -29,8 +31,8 @@ module TrophyApiClient
|
|
|
29
31
|
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
30
32
|
# api_key: "YOUR_API_KEY"
|
|
31
33
|
# )
|
|
32
|
-
# api.admin.streaks.restore(
|
|
33
|
-
def restore(
|
|
34
|
+
# api.admin.streaks.restore(users: [{ id: "user-123" }, { id: "user-456" }])
|
|
35
|
+
def restore(users:, request_options: nil)
|
|
34
36
|
response = @request_client.conn.post do |req|
|
|
35
37
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
36
38
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
@@ -42,7 +44,7 @@ module TrophyApiClient
|
|
|
42
44
|
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
43
45
|
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
44
46
|
end
|
|
45
|
-
req.body = { **(request_options&.additional_body_parameters || {}),
|
|
47
|
+
req.body = { **(request_options&.additional_body_parameters || {}), users: users }.compact
|
|
46
48
|
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/streaks/restore"
|
|
47
49
|
end
|
|
48
50
|
TrophyApiClient::RestoreStreaksResponse.from_json(json_object: response.body)
|
|
@@ -63,7 +65,8 @@ module TrophyApiClient
|
|
|
63
65
|
# the case of daily streaks), one year (in the case of weekly streaks), or two
|
|
64
66
|
# years (in the case of monthly streaks).
|
|
65
67
|
#
|
|
66
|
-
# @param
|
|
68
|
+
# @param users [Array<Hash>] Array of users to restore streaks for. Maximum 100 users per request.Request of type Array<TrophyApiClient::Admin::Streaks::RestoreStreaksRequestUsersItem>, as a Hash
|
|
69
|
+
# * :id (String)
|
|
67
70
|
# @param request_options [TrophyApiClient::RequestOptions]
|
|
68
71
|
# @return [TrophyApiClient::RestoreStreaksResponse]
|
|
69
72
|
# @example
|
|
@@ -72,8 +75,8 @@ module TrophyApiClient
|
|
|
72
75
|
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
73
76
|
# api_key: "YOUR_API_KEY"
|
|
74
77
|
# )
|
|
75
|
-
# api.admin.streaks.restore(
|
|
76
|
-
def restore(
|
|
78
|
+
# api.admin.streaks.restore(users: [{ id: "user-123" }, { id: "user-456" }])
|
|
79
|
+
def restore(users:, request_options: nil)
|
|
77
80
|
Async do
|
|
78
81
|
response = @request_client.conn.post do |req|
|
|
79
82
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
@@ -86,7 +89,7 @@ module TrophyApiClient
|
|
|
86
89
|
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
87
90
|
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
88
91
|
end
|
|
89
|
-
req.body = { **(request_options&.additional_body_parameters || {}),
|
|
92
|
+
req.body = { **(request_options&.additional_body_parameters || {}), users: users }.compact
|
|
90
93
|
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/streaks/restore"
|
|
91
94
|
end
|
|
92
95
|
TrophyApiClient::RestoreStreaksResponse.from_json(json_object: response.body)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "ostruct"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module TrophyApiClient
|
|
7
|
+
module Admin
|
|
8
|
+
class Streaks
|
|
9
|
+
class RestoreStreaksRequestUsersItem
|
|
10
|
+
# @return [String] The ID of the user to restore streaks for.
|
|
11
|
+
attr_reader :id
|
|
12
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
13
|
+
attr_reader :additional_properties
|
|
14
|
+
# @return [Object]
|
|
15
|
+
attr_reader :_field_set
|
|
16
|
+
protected :_field_set
|
|
17
|
+
|
|
18
|
+
OMIT = Object.new
|
|
19
|
+
|
|
20
|
+
# @param id [String] The ID of the user to restore streaks for.
|
|
21
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
22
|
+
# @return [TrophyApiClient::Admin::Streaks::RestoreStreaksRequestUsersItem]
|
|
23
|
+
def initialize(id:, additional_properties: nil)
|
|
24
|
+
@id = id
|
|
25
|
+
@additional_properties = additional_properties
|
|
26
|
+
@_field_set = { "id": id }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Deserialize a JSON object to an instance of RestoreStreaksRequestUsersItem
|
|
30
|
+
#
|
|
31
|
+
# @param json_object [String]
|
|
32
|
+
# @return [TrophyApiClient::Admin::Streaks::RestoreStreaksRequestUsersItem]
|
|
33
|
+
def self.from_json(json_object:)
|
|
34
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
35
|
+
parsed_json = JSON.parse(json_object)
|
|
36
|
+
id = parsed_json["id"]
|
|
37
|
+
new(id: id, additional_properties: struct)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Serialize an instance of RestoreStreaksRequestUsersItem to a JSON object
|
|
41
|
+
#
|
|
42
|
+
# @return [String]
|
|
43
|
+
def to_json(*_args)
|
|
44
|
+
@_field_set&.to_json
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
48
|
+
# hash and check each fields type against the current object's property
|
|
49
|
+
# definitions.
|
|
50
|
+
#
|
|
51
|
+
# @param obj [Object]
|
|
52
|
+
# @return [Void]
|
|
53
|
+
def self.validate_raw(obj:)
|
|
54
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "
|
|
3
|
+
require_relative "user_achievement_response"
|
|
4
4
|
require "ostruct"
|
|
5
5
|
require "json"
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ module TrophyApiClient
|
|
|
8
8
|
class AchievementCompletionResponse
|
|
9
9
|
# @return [String] The unique ID of the completion.
|
|
10
10
|
attr_reader :completion_id
|
|
11
|
-
# @return [TrophyApiClient::
|
|
11
|
+
# @return [TrophyApiClient::UserAchievementResponse]
|
|
12
12
|
attr_reader :achievement
|
|
13
13
|
# @return [Hash{String => TrophyApiClient::MetricEventPointsResponse}] A map of points systems by key that were affected by this achievement
|
|
14
14
|
# completion.
|
|
@@ -22,7 +22,7 @@ module TrophyApiClient
|
|
|
22
22
|
OMIT = Object.new
|
|
23
23
|
|
|
24
24
|
# @param completion_id [String] The unique ID of the completion.
|
|
25
|
-
# @param achievement [TrophyApiClient::
|
|
25
|
+
# @param achievement [TrophyApiClient::UserAchievementResponse]
|
|
26
26
|
# @param points [Hash{String => TrophyApiClient::MetricEventPointsResponse}] A map of points systems by key that were affected by this achievement
|
|
27
27
|
# completion.
|
|
28
28
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
@@ -47,7 +47,7 @@ module TrophyApiClient
|
|
|
47
47
|
achievement = nil
|
|
48
48
|
else
|
|
49
49
|
achievement = parsed_json["achievement"].to_json
|
|
50
|
-
achievement = TrophyApiClient::
|
|
50
|
+
achievement = TrophyApiClient::UserAchievementResponse.from_json(json_object: achievement)
|
|
51
51
|
end
|
|
52
52
|
points = parsed_json["points"]&.transform_values do |value|
|
|
53
53
|
value = value.to_json
|
|
@@ -76,7 +76,7 @@ module TrophyApiClient
|
|
|
76
76
|
# @return [Void]
|
|
77
77
|
def self.validate_raw(obj:)
|
|
78
78
|
obj.completion_id.is_a?(String) != false || raise("Passed value for field obj.completion_id is not the expected type, validation failed.")
|
|
79
|
-
TrophyApiClient::
|
|
79
|
+
TrophyApiClient::UserAchievementResponse.validate_raw(obj: obj.achievement)
|
|
80
80
|
obj.points.is_a?(Hash) != false || raise("Passed value for field obj.points is not the expected type, validation failed.")
|
|
81
81
|
end
|
|
82
82
|
end
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "achievement_response_trigger"
|
|
4
|
+
require_relative "achievement_response_user_attributes_item"
|
|
5
|
+
require_relative "achievement_response_event_attribute"
|
|
4
6
|
require "ostruct"
|
|
5
7
|
require "json"
|
|
6
8
|
|
|
@@ -31,6 +33,12 @@ module TrophyApiClient
|
|
|
31
33
|
# @return [String] The name of the metric associated with this achievement (only applicable if
|
|
32
34
|
# trigger = 'metric')
|
|
33
35
|
attr_reader :metric_name
|
|
36
|
+
# @return [Array<TrophyApiClient::AchievementResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
|
|
37
|
+
# Only present if the achievement has user attribute filters configured.
|
|
38
|
+
attr_reader :user_attributes
|
|
39
|
+
# @return [TrophyApiClient::AchievementResponseEventAttribute] Event attribute filter that must be met for this achievement to be completed.
|
|
40
|
+
# Only present if the achievement has an event filter configured.
|
|
41
|
+
attr_reader :event_attribute
|
|
34
42
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
35
43
|
attr_reader :additional_properties
|
|
36
44
|
# @return [Object]
|
|
@@ -54,20 +62,26 @@ module TrophyApiClient
|
|
|
54
62
|
# trigger = 'metric')
|
|
55
63
|
# @param metric_name [String] The name of the metric associated with this achievement (only applicable if
|
|
56
64
|
# trigger = 'metric')
|
|
65
|
+
# @param user_attributes [Array<TrophyApiClient::AchievementResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
|
|
66
|
+
# Only present if the achievement has user attribute filters configured.
|
|
67
|
+
# @param event_attribute [TrophyApiClient::AchievementResponseEventAttribute] Event attribute filter that must be met for this achievement to be completed.
|
|
68
|
+
# Only present if the achievement has an event filter configured.
|
|
57
69
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
58
70
|
# @return [TrophyApiClient::AchievementResponse]
|
|
59
|
-
def initialize(id:, name:, trigger:,
|
|
60
|
-
metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, additional_properties: nil)
|
|
71
|
+
def initialize(id:, name:, trigger:, description: OMIT, badge_url: OMIT, key: OMIT, streak_length: OMIT,
|
|
72
|
+
metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, user_attributes: OMIT, event_attribute: OMIT, additional_properties: nil)
|
|
61
73
|
@id = id
|
|
62
74
|
@name = name
|
|
63
75
|
@trigger = trigger
|
|
64
76
|
@description = description if description != OMIT
|
|
65
77
|
@badge_url = badge_url if badge_url != OMIT
|
|
66
|
-
@key = key
|
|
78
|
+
@key = key if key != OMIT
|
|
67
79
|
@streak_length = streak_length if streak_length != OMIT
|
|
68
80
|
@metric_id = metric_id if metric_id != OMIT
|
|
69
81
|
@metric_value = metric_value if metric_value != OMIT
|
|
70
82
|
@metric_name = metric_name if metric_name != OMIT
|
|
83
|
+
@user_attributes = user_attributes if user_attributes != OMIT
|
|
84
|
+
@event_attribute = event_attribute if event_attribute != OMIT
|
|
71
85
|
@additional_properties = additional_properties
|
|
72
86
|
@_field_set = {
|
|
73
87
|
"id": id,
|
|
@@ -79,7 +93,9 @@ module TrophyApiClient
|
|
|
79
93
|
"streakLength": streak_length,
|
|
80
94
|
"metricId": metric_id,
|
|
81
95
|
"metricValue": metric_value,
|
|
82
|
-
"metricName": metric_name
|
|
96
|
+
"metricName": metric_name,
|
|
97
|
+
"userAttributes": user_attributes,
|
|
98
|
+
"eventAttribute": event_attribute
|
|
83
99
|
}.reject do |_k, v|
|
|
84
100
|
v == OMIT
|
|
85
101
|
end
|
|
@@ -102,6 +118,16 @@ module TrophyApiClient
|
|
|
102
118
|
metric_id = parsed_json["metricId"]
|
|
103
119
|
metric_value = parsed_json["metricValue"]
|
|
104
120
|
metric_name = parsed_json["metricName"]
|
|
121
|
+
user_attributes = parsed_json["userAttributes"]&.map do |item|
|
|
122
|
+
item = item.to_json
|
|
123
|
+
TrophyApiClient::AchievementResponseUserAttributesItem.from_json(json_object: item)
|
|
124
|
+
end
|
|
125
|
+
if parsed_json["eventAttribute"].nil?
|
|
126
|
+
event_attribute = nil
|
|
127
|
+
else
|
|
128
|
+
event_attribute = parsed_json["eventAttribute"].to_json
|
|
129
|
+
event_attribute = TrophyApiClient::AchievementResponseEventAttribute.from_json(json_object: event_attribute)
|
|
130
|
+
end
|
|
105
131
|
new(
|
|
106
132
|
id: id,
|
|
107
133
|
name: name,
|
|
@@ -113,6 +139,8 @@ module TrophyApiClient
|
|
|
113
139
|
metric_id: metric_id,
|
|
114
140
|
metric_value: metric_value,
|
|
115
141
|
metric_name: metric_name,
|
|
142
|
+
user_attributes: user_attributes,
|
|
143
|
+
event_attribute: event_attribute,
|
|
116
144
|
additional_properties: struct
|
|
117
145
|
)
|
|
118
146
|
end
|
|
@@ -136,11 +164,13 @@ module TrophyApiClient
|
|
|
136
164
|
obj.trigger.is_a?(TrophyApiClient::AchievementResponseTrigger) != false || raise("Passed value for field obj.trigger is not the expected type, validation failed.")
|
|
137
165
|
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
|
138
166
|
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
|
139
|
-
obj.key
|
|
167
|
+
obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
140
168
|
obj.streak_length&.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.")
|
|
141
169
|
obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
|
|
142
170
|
obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
|
|
143
171
|
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
|
172
|
+
obj.user_attributes&.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.")
|
|
173
|
+
obj.event_attribute.nil? || TrophyApiClient::AchievementResponseEventAttribute.validate_raw(obj: obj.event_attribute)
|
|
144
174
|
end
|
|
145
175
|
end
|
|
146
176
|
end
|
|
@@ -6,7 +6,7 @@ require "json"
|
|
|
6
6
|
module TrophyApiClient
|
|
7
7
|
# Event attribute filter that must be met for this achievement to be completed.
|
|
8
8
|
# Only present if the achievement has an event filter configured.
|
|
9
|
-
class
|
|
9
|
+
class AchievementResponseEventAttribute
|
|
10
10
|
# @return [String] The key of the event attribute.
|
|
11
11
|
attr_reader :key
|
|
12
12
|
# @return [String] The value of the event attribute.
|
|
@@ -22,7 +22,7 @@ module TrophyApiClient
|
|
|
22
22
|
# @param key [String] The key of the event attribute.
|
|
23
23
|
# @param value [String] The value of the event attribute.
|
|
24
24
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
25
|
-
# @return [TrophyApiClient::
|
|
25
|
+
# @return [TrophyApiClient::AchievementResponseEventAttribute]
|
|
26
26
|
def initialize(key:, value:, additional_properties: nil)
|
|
27
27
|
@key = key
|
|
28
28
|
@value = value
|
|
@@ -30,11 +30,10 @@ module TrophyApiClient
|
|
|
30
30
|
@_field_set = { "key": key, "value": value }
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
# Deserialize a JSON object to an instance of
|
|
34
|
-
# AchievementWithStatsResponseEventAttribute
|
|
33
|
+
# Deserialize a JSON object to an instance of AchievementResponseEventAttribute
|
|
35
34
|
#
|
|
36
35
|
# @param json_object [String]
|
|
37
|
-
# @return [TrophyApiClient::
|
|
36
|
+
# @return [TrophyApiClient::AchievementResponseEventAttribute]
|
|
38
37
|
def self.from_json(json_object:)
|
|
39
38
|
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
40
39
|
parsed_json = JSON.parse(json_object)
|
|
@@ -47,8 +46,7 @@ module TrophyApiClient
|
|
|
47
46
|
)
|
|
48
47
|
end
|
|
49
48
|
|
|
50
|
-
# Serialize an instance of
|
|
51
|
-
# object
|
|
49
|
+
# Serialize an instance of AchievementResponseEventAttribute to a JSON object
|
|
52
50
|
#
|
|
53
51
|
# @return [String]
|
|
54
52
|
def to_json(*_args)
|
|
@@ -4,7 +4,7 @@ require "ostruct"
|
|
|
4
4
|
require "json"
|
|
5
5
|
|
|
6
6
|
module TrophyApiClient
|
|
7
|
-
class
|
|
7
|
+
class AchievementResponseUserAttributesItem
|
|
8
8
|
# @return [String] The key of the user attribute.
|
|
9
9
|
attr_reader :key
|
|
10
10
|
# @return [String] The value of the user attribute.
|
|
@@ -20,7 +20,7 @@ module TrophyApiClient
|
|
|
20
20
|
# @param key [String] The key of the user attribute.
|
|
21
21
|
# @param value [String] The value of the user attribute.
|
|
22
22
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
23
|
-
# @return [TrophyApiClient::
|
|
23
|
+
# @return [TrophyApiClient::AchievementResponseUserAttributesItem]
|
|
24
24
|
def initialize(key:, value:, additional_properties: nil)
|
|
25
25
|
@key = key
|
|
26
26
|
@value = value
|
|
@@ -29,10 +29,10 @@ module TrophyApiClient
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
# Deserialize a JSON object to an instance of
|
|
32
|
-
#
|
|
32
|
+
# AchievementResponseUserAttributesItem
|
|
33
33
|
#
|
|
34
34
|
# @param json_object [String]
|
|
35
|
-
# @return [TrophyApiClient::
|
|
35
|
+
# @return [TrophyApiClient::AchievementResponseUserAttributesItem]
|
|
36
36
|
def self.from_json(json_object:)
|
|
37
37
|
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
38
38
|
parsed_json = JSON.parse(json_object)
|
|
@@ -45,8 +45,7 @@ module TrophyApiClient
|
|
|
45
45
|
)
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
# Serialize an instance of
|
|
49
|
-
# JSON object
|
|
48
|
+
# Serialize an instance of AchievementResponseUserAttributesItem to a JSON object
|
|
50
49
|
#
|
|
51
50
|
# @return [String]
|
|
52
51
|
def to_json(*_args)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "achievement_with_stats_response_user_attributes_item"
|
|
4
|
-
require_relative "achievement_with_stats_response_event_attribute"
|
|
5
3
|
require_relative "achievement_response_trigger"
|
|
4
|
+
require_relative "achievement_response_user_attributes_item"
|
|
5
|
+
require_relative "achievement_response_event_attribute"
|
|
6
6
|
require "ostruct"
|
|
7
7
|
require "json"
|
|
8
8
|
|
|
@@ -12,12 +12,6 @@ module TrophyApiClient
|
|
|
12
12
|
attr_reader :completions
|
|
13
13
|
# @return [Float] The percentage of all users who have completed this achievement.
|
|
14
14
|
attr_reader :rarity
|
|
15
|
-
# @return [Array<TrophyApiClient::AchievementWithStatsResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
|
|
16
|
-
# Only present if the achievement has user attribute filters configured.
|
|
17
|
-
attr_reader :user_attributes
|
|
18
|
-
# @return [TrophyApiClient::AchievementWithStatsResponseEventAttribute] Event attribute filter that must be met for this achievement to be completed.
|
|
19
|
-
# Only present if the achievement has an event filter configured.
|
|
20
|
-
attr_reader :event_attribute
|
|
21
15
|
# @return [String] The unique ID of the achievement.
|
|
22
16
|
attr_reader :id
|
|
23
17
|
# @return [String] The name of this achievement.
|
|
@@ -43,6 +37,12 @@ module TrophyApiClient
|
|
|
43
37
|
# @return [String] The name of the metric associated with this achievement (only applicable if
|
|
44
38
|
# trigger = 'metric')
|
|
45
39
|
attr_reader :metric_name
|
|
40
|
+
# @return [Array<TrophyApiClient::AchievementResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
|
|
41
|
+
# Only present if the achievement has user attribute filters configured.
|
|
42
|
+
attr_reader :user_attributes
|
|
43
|
+
# @return [TrophyApiClient::AchievementResponseEventAttribute] Event attribute filter that must be met for this achievement to be completed.
|
|
44
|
+
# Only present if the achievement has an event filter configured.
|
|
45
|
+
attr_reader :event_attribute
|
|
46
46
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
47
47
|
attr_reader :additional_properties
|
|
48
48
|
# @return [Object]
|
|
@@ -53,10 +53,6 @@ module TrophyApiClient
|
|
|
53
53
|
|
|
54
54
|
# @param completions [Integer] The number of users who have completed this achievement.
|
|
55
55
|
# @param rarity [Float] The percentage of all users who have completed this achievement.
|
|
56
|
-
# @param user_attributes [Array<TrophyApiClient::AchievementWithStatsResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
|
|
57
|
-
# Only present if the achievement has user attribute filters configured.
|
|
58
|
-
# @param event_attribute [TrophyApiClient::AchievementWithStatsResponseEventAttribute] Event attribute filter that must be met for this achievement to be completed.
|
|
59
|
-
# Only present if the achievement has an event filter configured.
|
|
60
56
|
# @param id [String] The unique ID of the achievement.
|
|
61
57
|
# @param name [String] The name of this achievement.
|
|
62
58
|
# @param trigger [TrophyApiClient::AchievementResponseTrigger] The trigger of the achievement.
|
|
@@ -72,30 +68,32 @@ module TrophyApiClient
|
|
|
72
68
|
# trigger = 'metric')
|
|
73
69
|
# @param metric_name [String] The name of the metric associated with this achievement (only applicable if
|
|
74
70
|
# trigger = 'metric')
|
|
71
|
+
# @param user_attributes [Array<TrophyApiClient::AchievementResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
|
|
72
|
+
# Only present if the achievement has user attribute filters configured.
|
|
73
|
+
# @param event_attribute [TrophyApiClient::AchievementResponseEventAttribute] Event attribute filter that must be met for this achievement to be completed.
|
|
74
|
+
# Only present if the achievement has an event filter configured.
|
|
75
75
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
76
76
|
# @return [TrophyApiClient::AchievementWithStatsResponse]
|
|
77
|
-
def initialize(completions:, rarity:, id:, name:, trigger:,
|
|
78
|
-
|
|
77
|
+
def initialize(completions:, rarity:, id:, name:, trigger:, description: OMIT, badge_url: OMIT, key: OMIT,
|
|
78
|
+
streak_length: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, user_attributes: OMIT, event_attribute: OMIT, additional_properties: nil)
|
|
79
79
|
@completions = completions
|
|
80
80
|
@rarity = rarity
|
|
81
|
-
@user_attributes = user_attributes if user_attributes != OMIT
|
|
82
|
-
@event_attribute = event_attribute if event_attribute != OMIT
|
|
83
81
|
@id = id
|
|
84
82
|
@name = name
|
|
85
83
|
@trigger = trigger
|
|
86
84
|
@description = description if description != OMIT
|
|
87
85
|
@badge_url = badge_url if badge_url != OMIT
|
|
88
|
-
@key = key
|
|
86
|
+
@key = key if key != OMIT
|
|
89
87
|
@streak_length = streak_length if streak_length != OMIT
|
|
90
88
|
@metric_id = metric_id if metric_id != OMIT
|
|
91
89
|
@metric_value = metric_value if metric_value != OMIT
|
|
92
90
|
@metric_name = metric_name if metric_name != OMIT
|
|
91
|
+
@user_attributes = user_attributes if user_attributes != OMIT
|
|
92
|
+
@event_attribute = event_attribute if event_attribute != OMIT
|
|
93
93
|
@additional_properties = additional_properties
|
|
94
94
|
@_field_set = {
|
|
95
95
|
"completions": completions,
|
|
96
96
|
"rarity": rarity,
|
|
97
|
-
"userAttributes": user_attributes,
|
|
98
|
-
"eventAttribute": event_attribute,
|
|
99
97
|
"id": id,
|
|
100
98
|
"name": name,
|
|
101
99
|
"trigger": trigger,
|
|
@@ -105,7 +103,9 @@ module TrophyApiClient
|
|
|
105
103
|
"streakLength": streak_length,
|
|
106
104
|
"metricId": metric_id,
|
|
107
105
|
"metricValue": metric_value,
|
|
108
|
-
"metricName": metric_name
|
|
106
|
+
"metricName": metric_name,
|
|
107
|
+
"userAttributes": user_attributes,
|
|
108
|
+
"eventAttribute": event_attribute
|
|
109
109
|
}.reject do |_k, v|
|
|
110
110
|
v == OMIT
|
|
111
111
|
end
|
|
@@ -120,16 +120,6 @@ module TrophyApiClient
|
|
|
120
120
|
parsed_json = JSON.parse(json_object)
|
|
121
121
|
completions = parsed_json["completions"]
|
|
122
122
|
rarity = parsed_json["rarity"]
|
|
123
|
-
user_attributes = parsed_json["userAttributes"]&.map do |item|
|
|
124
|
-
item = item.to_json
|
|
125
|
-
TrophyApiClient::AchievementWithStatsResponseUserAttributesItem.from_json(json_object: item)
|
|
126
|
-
end
|
|
127
|
-
if parsed_json["eventAttribute"].nil?
|
|
128
|
-
event_attribute = nil
|
|
129
|
-
else
|
|
130
|
-
event_attribute = parsed_json["eventAttribute"].to_json
|
|
131
|
-
event_attribute = TrophyApiClient::AchievementWithStatsResponseEventAttribute.from_json(json_object: event_attribute)
|
|
132
|
-
end
|
|
133
123
|
id = parsed_json["id"]
|
|
134
124
|
name = parsed_json["name"]
|
|
135
125
|
trigger = parsed_json["trigger"]
|
|
@@ -140,11 +130,19 @@ module TrophyApiClient
|
|
|
140
130
|
metric_id = parsed_json["metricId"]
|
|
141
131
|
metric_value = parsed_json["metricValue"]
|
|
142
132
|
metric_name = parsed_json["metricName"]
|
|
133
|
+
user_attributes = parsed_json["userAttributes"]&.map do |item|
|
|
134
|
+
item = item.to_json
|
|
135
|
+
TrophyApiClient::AchievementResponseUserAttributesItem.from_json(json_object: item)
|
|
136
|
+
end
|
|
137
|
+
if parsed_json["eventAttribute"].nil?
|
|
138
|
+
event_attribute = nil
|
|
139
|
+
else
|
|
140
|
+
event_attribute = parsed_json["eventAttribute"].to_json
|
|
141
|
+
event_attribute = TrophyApiClient::AchievementResponseEventAttribute.from_json(json_object: event_attribute)
|
|
142
|
+
end
|
|
143
143
|
new(
|
|
144
144
|
completions: completions,
|
|
145
145
|
rarity: rarity,
|
|
146
|
-
user_attributes: user_attributes,
|
|
147
|
-
event_attribute: event_attribute,
|
|
148
146
|
id: id,
|
|
149
147
|
name: name,
|
|
150
148
|
trigger: trigger,
|
|
@@ -155,6 +153,8 @@ module TrophyApiClient
|
|
|
155
153
|
metric_id: metric_id,
|
|
156
154
|
metric_value: metric_value,
|
|
157
155
|
metric_name: metric_name,
|
|
156
|
+
user_attributes: user_attributes,
|
|
157
|
+
event_attribute: event_attribute,
|
|
158
158
|
additional_properties: struct
|
|
159
159
|
)
|
|
160
160
|
end
|
|
@@ -175,18 +175,18 @@ module TrophyApiClient
|
|
|
175
175
|
def self.validate_raw(obj:)
|
|
176
176
|
obj.completions.is_a?(Integer) != false || raise("Passed value for field obj.completions is not the expected type, validation failed.")
|
|
177
177
|
obj.rarity.is_a?(Float) != false || raise("Passed value for field obj.rarity is not the expected type, validation failed.")
|
|
178
|
-
obj.user_attributes&.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.")
|
|
179
|
-
obj.event_attribute.nil? || TrophyApiClient::AchievementWithStatsResponseEventAttribute.validate_raw(obj: obj.event_attribute)
|
|
180
178
|
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
|
181
179
|
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
182
180
|
obj.trigger.is_a?(TrophyApiClient::AchievementResponseTrigger) != false || raise("Passed value for field obj.trigger is not the expected type, validation failed.")
|
|
183
181
|
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
|
184
182
|
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
|
185
|
-
obj.key
|
|
183
|
+
obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
186
184
|
obj.streak_length&.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.")
|
|
187
185
|
obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
|
|
188
186
|
obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
|
|
189
187
|
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
|
188
|
+
obj.user_attributes&.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.")
|
|
189
|
+
obj.event_attribute.nil? || TrophyApiClient::AchievementResponseEventAttribute.validate_raw(obj: obj.event_attribute)
|
|
190
190
|
end
|
|
191
191
|
end
|
|
192
192
|
end
|
|
@@ -9,7 +9,8 @@ module TrophyApiClient
|
|
|
9
9
|
attr_reader :user_id
|
|
10
10
|
# @return [Integer] The length of the user's streak.
|
|
11
11
|
attr_reader :streak_length
|
|
12
|
-
# @return [String] The timestamp the streak was extended, as a string.
|
|
12
|
+
# @return [String] The timestamp the streak was extended, as a string. Null if the streak is not
|
|
13
|
+
# active.
|
|
13
14
|
attr_reader :extended
|
|
14
15
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
15
16
|
attr_reader :additional_properties
|
|
@@ -21,15 +22,18 @@ module TrophyApiClient
|
|
|
21
22
|
|
|
22
23
|
# @param user_id [String] The ID of the user.
|
|
23
24
|
# @param streak_length [Integer] The length of the user's streak.
|
|
24
|
-
# @param extended [String] The timestamp the streak was extended, as a string.
|
|
25
|
+
# @param extended [String] The timestamp the streak was extended, as a string. Null if the streak is not
|
|
26
|
+
# active.
|
|
25
27
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
26
28
|
# @return [TrophyApiClient::BulkStreakResponseItem]
|
|
27
|
-
def initialize(user_id:, streak_length:, extended
|
|
29
|
+
def initialize(user_id:, streak_length:, extended: OMIT, additional_properties: nil)
|
|
28
30
|
@user_id = user_id
|
|
29
31
|
@streak_length = streak_length
|
|
30
|
-
@extended = extended
|
|
32
|
+
@extended = extended if extended != OMIT
|
|
31
33
|
@additional_properties = additional_properties
|
|
32
|
-
@_field_set = { "userId": user_id, "streakLength": streak_length, "extended": extended }
|
|
34
|
+
@_field_set = { "userId": user_id, "streakLength": streak_length, "extended": extended }.reject do |_k, v|
|
|
35
|
+
v == OMIT
|
|
36
|
+
end
|
|
33
37
|
end
|
|
34
38
|
|
|
35
39
|
# Deserialize a JSON object to an instance of BulkStreakResponseItem
|
|
@@ -66,7 +70,7 @@ module TrophyApiClient
|
|
|
66
70
|
def self.validate_raw(obj:)
|
|
67
71
|
obj.user_id.is_a?(String) != false || raise("Passed value for field obj.user_id is not the expected type, validation failed.")
|
|
68
72
|
obj.streak_length.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.")
|
|
69
|
-
obj.extended
|
|
73
|
+
obj.extended&.is_a?(String) != false || raise("Passed value for field obj.extended is not the expected type, validation failed.")
|
|
70
74
|
end
|
|
71
75
|
end
|
|
72
76
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "
|
|
3
|
+
require_relative "user_achievement_response"
|
|
4
4
|
require_relative "metric_event_streak_response"
|
|
5
5
|
require "ostruct"
|
|
6
6
|
require "json"
|
|
@@ -13,7 +13,7 @@ module TrophyApiClient
|
|
|
13
13
|
attr_reader :metric_id
|
|
14
14
|
# @return [Float] The user's new total progress against the metric.
|
|
15
15
|
attr_reader :total
|
|
16
|
-
# @return [Array<TrophyApiClient::
|
|
16
|
+
# @return [Array<TrophyApiClient::UserAchievementResponse>] Achievements completed as a result of this event.
|
|
17
17
|
attr_reader :achievements
|
|
18
18
|
# @return [TrophyApiClient::MetricEventStreakResponse] The user's current streak.
|
|
19
19
|
attr_reader :current_streak
|
|
@@ -38,7 +38,7 @@ module TrophyApiClient
|
|
|
38
38
|
# @param event_id [String] The unique ID of the event.
|
|
39
39
|
# @param metric_id [String] The unique ID of the metric that was updated.
|
|
40
40
|
# @param total [Float] The user's new total progress against the metric.
|
|
41
|
-
# @param achievements [Array<TrophyApiClient::
|
|
41
|
+
# @param achievements [Array<TrophyApiClient::UserAchievementResponse>] Achievements completed as a result of this event.
|
|
42
42
|
# @param current_streak [TrophyApiClient::MetricEventStreakResponse] The user's current streak.
|
|
43
43
|
# @param points [Hash{String => TrophyApiClient::MetricEventPointsResponse}] A map of points systems by key. Only contains points systems that were affected
|
|
44
44
|
# by the event.
|
|
@@ -87,7 +87,7 @@ module TrophyApiClient
|
|
|
87
87
|
total = parsed_json["total"]
|
|
88
88
|
achievements = parsed_json["achievements"]&.map do |item|
|
|
89
89
|
item = item.to_json
|
|
90
|
-
TrophyApiClient::
|
|
90
|
+
TrophyApiClient::UserAchievementResponse.from_json(json_object: item)
|
|
91
91
|
end
|
|
92
92
|
if parsed_json["currentStreak"].nil?
|
|
93
93
|
current_streak = nil
|