trophy_api_client 1.0.10 → 1.0.11
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/points/client.rb +175 -0
- data/lib/trophy_api_client/types/achievement_response.rb +20 -5
- data/lib/trophy_api_client/types/achievement_response_trigger.rb +10 -0
- data/lib/trophy_api_client/types/achievement_with_stats_response.rb +20 -5
- data/lib/trophy_api_client/types/completed_achievement_response.rb +20 -5
- data/lib/trophy_api_client/types/event_response.rb +24 -7
- data/lib/trophy_api_client/types/get_user_points_response.rb +71 -0
- data/lib/trophy_api_client/types/metric_event_points_response.rb +78 -0
- data/lib/trophy_api_client/types/{increment_metric_streak_response.rb → metric_event_streak_response.rb} +6 -6
- data/lib/trophy_api_client/types/points_award.rb +80 -0
- data/lib/trophy_api_client/types/points_range.rb +74 -0
- data/lib/trophy_api_client/types/points_summary_response.rb +7 -0
- data/lib/trophy_api_client/types/points_trigger.rb +116 -0
- data/lib/trophy_api_client/types/points_trigger_response.rb +164 -0
- data/lib/trophy_api_client/types/points_trigger_response_status.rb +9 -0
- data/lib/trophy_api_client/types/points_trigger_response_type.rb +10 -0
- data/lib/trophy_api_client/types/points_trigger_type.rb +10 -0
- data/lib/trophy_api_client/users/client.rb +167 -0
- data/lib/trophy_api_client/users/types/users_points_event_summary_request_aggregation.rb +11 -0
- data/lib/trophy_api_client/users/types/users_points_event_summary_response_item.rb +76 -0
- data/lib/trophy_api_client/version.rb +1 -1
- data/lib/trophy_api_client.rb +7 -0
- data/lib/types_export.rb +14 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc623851107ae5d8fee5d6ab4676fa4bdbeb45b832a54666422db99ffc88667e
|
4
|
+
data.tar.gz: 53ca591d79257162bed574589d45bff4441c9073a093d2484b8c9c18a8bcc4ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96f1ba1f2ea0df15e83671b68c55f686e0343e00c072c6b966e4def6092ae45d69d7de95e1e67242e464be372e6bae8b7b37c814e48366b6ae96ca280296ccb9
|
7
|
+
data.tar.gz: 1b4f6735adaf1f1c9d3611da33531fb24a5decde550bb83672f820ff25496d28e27d13b79e1a327995575dd5f4ccf9127adce55d2433bb46ea7f5537c7638c3c
|
data/lib/gemconfig.rb
CHANGED
@@ -0,0 +1,175 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../requests"
|
4
|
+
require_relative "../types/points_summary_response"
|
5
|
+
require "json"
|
6
|
+
require_relative "../types/points_trigger_response"
|
7
|
+
require "async"
|
8
|
+
|
9
|
+
module TrophyApiClient
|
10
|
+
class PointsClient
|
11
|
+
# @return [TrophyApiClient::RequestClient]
|
12
|
+
attr_reader :request_client
|
13
|
+
|
14
|
+
# @param request_client [TrophyApiClient::RequestClient]
|
15
|
+
# @return [TrophyApiClient::PointsClient]
|
16
|
+
def initialize(request_client:)
|
17
|
+
@request_client = request_client
|
18
|
+
end
|
19
|
+
|
20
|
+
# Get a breakdown of the number of users with points in each range.
|
21
|
+
#
|
22
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
23
|
+
# @return [TrophyApiClient::POINTS_SUMMARY_RESPONSE]
|
24
|
+
# @example
|
25
|
+
# api = TrophyApiClient::Client.new(
|
26
|
+
# base_url: "https://api.example.com",
|
27
|
+
# environment: TrophyApiClient::Environment::DEFAULT,
|
28
|
+
# api_key: "YOUR_API_KEY"
|
29
|
+
# )
|
30
|
+
# api.points.summary
|
31
|
+
def summary(request_options: nil)
|
32
|
+
response = @request_client.conn.get do |req|
|
33
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
34
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
35
|
+
req.headers = {
|
36
|
+
**(req.headers || {}),
|
37
|
+
**@request_client.get_headers,
|
38
|
+
**(request_options&.additional_headers || {})
|
39
|
+
}.compact
|
40
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
41
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
42
|
+
end
|
43
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
44
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
45
|
+
end
|
46
|
+
req.url "#{@request_client.get_url(request_options: request_options)}/points/summary"
|
47
|
+
end
|
48
|
+
parsed_json = JSON.parse(response.body)
|
49
|
+
parsed_json&.map do |item|
|
50
|
+
item = item.to_json
|
51
|
+
TrophyApiClient::PointsRange.from_json(json_object: item)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Get all points triggers.
|
56
|
+
#
|
57
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
58
|
+
# @return [Array<TrophyApiClient::PointsTriggerResponse>]
|
59
|
+
# @example
|
60
|
+
# api = TrophyApiClient::Client.new(
|
61
|
+
# base_url: "https://api.example.com",
|
62
|
+
# environment: TrophyApiClient::Environment::DEFAULT,
|
63
|
+
# api_key: "YOUR_API_KEY"
|
64
|
+
# )
|
65
|
+
# api.points.triggers
|
66
|
+
def triggers(request_options: nil)
|
67
|
+
response = @request_client.conn.get do |req|
|
68
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
69
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
70
|
+
req.headers = {
|
71
|
+
**(req.headers || {}),
|
72
|
+
**@request_client.get_headers,
|
73
|
+
**(request_options&.additional_headers || {})
|
74
|
+
}.compact
|
75
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
76
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
77
|
+
end
|
78
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
79
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
80
|
+
end
|
81
|
+
req.url "#{@request_client.get_url(request_options: request_options)}/points/triggers"
|
82
|
+
end
|
83
|
+
parsed_json = JSON.parse(response.body)
|
84
|
+
parsed_json&.map do |item|
|
85
|
+
item = item.to_json
|
86
|
+
TrophyApiClient::PointsTriggerResponse.from_json(json_object: item)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
class AsyncPointsClient
|
92
|
+
# @return [TrophyApiClient::AsyncRequestClient]
|
93
|
+
attr_reader :request_client
|
94
|
+
|
95
|
+
# @param request_client [TrophyApiClient::AsyncRequestClient]
|
96
|
+
# @return [TrophyApiClient::AsyncPointsClient]
|
97
|
+
def initialize(request_client:)
|
98
|
+
@request_client = request_client
|
99
|
+
end
|
100
|
+
|
101
|
+
# Get a breakdown of the number of users with points in each range.
|
102
|
+
#
|
103
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
104
|
+
# @return [TrophyApiClient::POINTS_SUMMARY_RESPONSE]
|
105
|
+
# @example
|
106
|
+
# api = TrophyApiClient::Client.new(
|
107
|
+
# base_url: "https://api.example.com",
|
108
|
+
# environment: TrophyApiClient::Environment::DEFAULT,
|
109
|
+
# api_key: "YOUR_API_KEY"
|
110
|
+
# )
|
111
|
+
# api.points.summary
|
112
|
+
def summary(request_options: nil)
|
113
|
+
Async do
|
114
|
+
response = @request_client.conn.get do |req|
|
115
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
116
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
117
|
+
req.headers = {
|
118
|
+
**(req.headers || {}),
|
119
|
+
**@request_client.get_headers,
|
120
|
+
**(request_options&.additional_headers || {})
|
121
|
+
}.compact
|
122
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
123
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
124
|
+
end
|
125
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
126
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
127
|
+
end
|
128
|
+
req.url "#{@request_client.get_url(request_options: request_options)}/points/summary"
|
129
|
+
end
|
130
|
+
parsed_json = JSON.parse(response.body)
|
131
|
+
parsed_json&.map do |item|
|
132
|
+
item = item.to_json
|
133
|
+
TrophyApiClient::PointsRange.from_json(json_object: item)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
# Get all points triggers.
|
139
|
+
#
|
140
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
141
|
+
# @return [Array<TrophyApiClient::PointsTriggerResponse>]
|
142
|
+
# @example
|
143
|
+
# api = TrophyApiClient::Client.new(
|
144
|
+
# base_url: "https://api.example.com",
|
145
|
+
# environment: TrophyApiClient::Environment::DEFAULT,
|
146
|
+
# api_key: "YOUR_API_KEY"
|
147
|
+
# )
|
148
|
+
# api.points.triggers
|
149
|
+
def triggers(request_options: nil)
|
150
|
+
Async do
|
151
|
+
response = @request_client.conn.get do |req|
|
152
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
153
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
154
|
+
req.headers = {
|
155
|
+
**(req.headers || {}),
|
156
|
+
**@request_client.get_headers,
|
157
|
+
**(request_options&.additional_headers || {})
|
158
|
+
}.compact
|
159
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
160
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
161
|
+
end
|
162
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
163
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
164
|
+
end
|
165
|
+
req.url "#{@request_client.get_url(request_options: request_options)}/points/triggers"
|
166
|
+
end
|
167
|
+
parsed_json = JSON.parse(response.body)
|
168
|
+
parsed_json&.map do |item|
|
169
|
+
item = item.to_json
|
170
|
+
TrophyApiClient::PointsTriggerResponse.from_json(json_object: item)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "achievement_response_trigger"
|
4
|
+
require_relative "metric_event_streak_response"
|
3
5
|
require "ostruct"
|
4
6
|
require "json"
|
5
7
|
|
@@ -9,7 +11,7 @@ module TrophyApiClient
|
|
9
11
|
attr_reader :id
|
10
12
|
# @return [String] The name of this achievement.
|
11
13
|
attr_reader :name
|
12
|
-
# @return [
|
14
|
+
# @return [TrophyApiClient::AchievementResponseTrigger] The trigger of the achievement.
|
13
15
|
attr_reader :trigger
|
14
16
|
# @return [String] The description of this achievement.
|
15
17
|
attr_reader :description
|
@@ -30,6 +32,8 @@ module TrophyApiClient
|
|
30
32
|
# @return [String] The name of the metric associated with this achievement (only applicable if
|
31
33
|
# trigger = 'metric')
|
32
34
|
attr_reader :metric_name
|
35
|
+
# @return [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
36
|
+
attr_reader :current_streak
|
33
37
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
34
38
|
attr_reader :additional_properties
|
35
39
|
# @return [Object]
|
@@ -40,7 +44,7 @@ module TrophyApiClient
|
|
40
44
|
|
41
45
|
# @param id [String] The unique ID of the achievement.
|
42
46
|
# @param name [String] The name of this achievement.
|
43
|
-
# @param trigger [
|
47
|
+
# @param trigger [TrophyApiClient::AchievementResponseTrigger] The trigger of the achievement.
|
44
48
|
# @param description [String] The description of this achievement.
|
45
49
|
# @param badge_url [String] The URL of the badge image for the achievement, if one has been uploaded.
|
46
50
|
# @param key [String] The key used to reference this achievement in the API (only applicable if
|
@@ -53,10 +57,11 @@ module TrophyApiClient
|
|
53
57
|
# trigger = 'metric')
|
54
58
|
# @param metric_name [String] The name of the metric associated with this achievement (only applicable if
|
55
59
|
# trigger = 'metric')
|
60
|
+
# @param current_streak [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
56
61
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
57
62
|
# @return [TrophyApiClient::AchievementResponse]
|
58
63
|
def initialize(id:, name:, trigger:, description: OMIT, badge_url: OMIT, key: OMIT, streak_length: OMIT,
|
59
|
-
metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, additional_properties: nil)
|
64
|
+
metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, current_streak: OMIT, additional_properties: nil)
|
60
65
|
@id = id
|
61
66
|
@name = name
|
62
67
|
@trigger = trigger
|
@@ -67,6 +72,7 @@ module TrophyApiClient
|
|
67
72
|
@metric_id = metric_id if metric_id != OMIT
|
68
73
|
@metric_value = metric_value if metric_value != OMIT
|
69
74
|
@metric_name = metric_name if metric_name != OMIT
|
75
|
+
@current_streak = current_streak if current_streak != OMIT
|
70
76
|
@additional_properties = additional_properties
|
71
77
|
@_field_set = {
|
72
78
|
"id": id,
|
@@ -78,7 +84,8 @@ module TrophyApiClient
|
|
78
84
|
"streakLength": streak_length,
|
79
85
|
"metricId": metric_id,
|
80
86
|
"metricValue": metric_value,
|
81
|
-
"metricName": metric_name
|
87
|
+
"metricName": metric_name,
|
88
|
+
"currentStreak": current_streak
|
82
89
|
}.reject do |_k, v|
|
83
90
|
v == OMIT
|
84
91
|
end
|
@@ -101,6 +108,12 @@ module TrophyApiClient
|
|
101
108
|
metric_id = parsed_json["metricId"]
|
102
109
|
metric_value = parsed_json["metricValue"]
|
103
110
|
metric_name = parsed_json["metricName"]
|
111
|
+
if parsed_json["currentStreak"].nil?
|
112
|
+
current_streak = nil
|
113
|
+
else
|
114
|
+
current_streak = parsed_json["currentStreak"].to_json
|
115
|
+
current_streak = TrophyApiClient::MetricEventStreakResponse.from_json(json_object: current_streak)
|
116
|
+
end
|
104
117
|
new(
|
105
118
|
id: id,
|
106
119
|
name: name,
|
@@ -112,6 +125,7 @@ module TrophyApiClient
|
|
112
125
|
metric_id: metric_id,
|
113
126
|
metric_value: metric_value,
|
114
127
|
metric_name: metric_name,
|
128
|
+
current_streak: current_streak,
|
115
129
|
additional_properties: struct
|
116
130
|
)
|
117
131
|
end
|
@@ -132,7 +146,7 @@ module TrophyApiClient
|
|
132
146
|
def self.validate_raw(obj:)
|
133
147
|
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
134
148
|
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
135
|
-
obj.trigger.is_a?(
|
149
|
+
obj.trigger.is_a?(TrophyApiClient::AchievementResponseTrigger) != false || raise("Passed value for field obj.trigger is not the expected type, validation failed.")
|
136
150
|
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
137
151
|
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
138
152
|
obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
@@ -140,6 +154,7 @@ module TrophyApiClient
|
|
140
154
|
obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
|
141
155
|
obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
|
142
156
|
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
157
|
+
obj.current_streak.nil? || TrophyApiClient::MetricEventStreakResponse.validate_raw(obj: obj.current_streak)
|
143
158
|
end
|
144
159
|
end
|
145
160
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "achievement_response_trigger"
|
4
|
+
require_relative "metric_event_streak_response"
|
3
5
|
require "ostruct"
|
4
6
|
require "json"
|
5
7
|
|
@@ -13,7 +15,7 @@ module TrophyApiClient
|
|
13
15
|
attr_reader :id
|
14
16
|
# @return [String] The name of this achievement.
|
15
17
|
attr_reader :name
|
16
|
-
# @return [
|
18
|
+
# @return [TrophyApiClient::AchievementResponseTrigger] The trigger of the achievement.
|
17
19
|
attr_reader :trigger
|
18
20
|
# @return [String] The description of this achievement.
|
19
21
|
attr_reader :description
|
@@ -34,6 +36,8 @@ module TrophyApiClient
|
|
34
36
|
# @return [String] The name of the metric associated with this achievement (only applicable if
|
35
37
|
# trigger = 'metric')
|
36
38
|
attr_reader :metric_name
|
39
|
+
# @return [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
40
|
+
attr_reader :current_streak
|
37
41
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
38
42
|
attr_reader :additional_properties
|
39
43
|
# @return [Object]
|
@@ -46,7 +50,7 @@ module TrophyApiClient
|
|
46
50
|
# @param completed_percentage [Float] The percentage of all users who have completed this achievement.
|
47
51
|
# @param id [String] The unique ID of the achievement.
|
48
52
|
# @param name [String] The name of this achievement.
|
49
|
-
# @param trigger [
|
53
|
+
# @param trigger [TrophyApiClient::AchievementResponseTrigger] The trigger of the achievement.
|
50
54
|
# @param description [String] The description of this achievement.
|
51
55
|
# @param badge_url [String] The URL of the badge image for the achievement, if one has been uploaded.
|
52
56
|
# @param key [String] The key used to reference this achievement in the API (only applicable if
|
@@ -59,10 +63,11 @@ module TrophyApiClient
|
|
59
63
|
# trigger = 'metric')
|
60
64
|
# @param metric_name [String] The name of the metric associated with this achievement (only applicable if
|
61
65
|
# trigger = 'metric')
|
66
|
+
# @param current_streak [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
62
67
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
63
68
|
# @return [TrophyApiClient::AchievementWithStatsResponse]
|
64
69
|
def initialize(id:, name:, trigger:, completions: OMIT, completed_percentage: OMIT, description: OMIT,
|
65
|
-
badge_url: OMIT, key: OMIT, streak_length: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, additional_properties: nil)
|
70
|
+
badge_url: OMIT, key: OMIT, streak_length: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, current_streak: OMIT, additional_properties: nil)
|
66
71
|
@completions = completions if completions != OMIT
|
67
72
|
@completed_percentage = completed_percentage if completed_percentage != OMIT
|
68
73
|
@id = id
|
@@ -75,6 +80,7 @@ module TrophyApiClient
|
|
75
80
|
@metric_id = metric_id if metric_id != OMIT
|
76
81
|
@metric_value = metric_value if metric_value != OMIT
|
77
82
|
@metric_name = metric_name if metric_name != OMIT
|
83
|
+
@current_streak = current_streak if current_streak != OMIT
|
78
84
|
@additional_properties = additional_properties
|
79
85
|
@_field_set = {
|
80
86
|
"completions": completions,
|
@@ -88,7 +94,8 @@ module TrophyApiClient
|
|
88
94
|
"streakLength": streak_length,
|
89
95
|
"metricId": metric_id,
|
90
96
|
"metricValue": metric_value,
|
91
|
-
"metricName": metric_name
|
97
|
+
"metricName": metric_name,
|
98
|
+
"currentStreak": current_streak
|
92
99
|
}.reject do |_k, v|
|
93
100
|
v == OMIT
|
94
101
|
end
|
@@ -113,6 +120,12 @@ module TrophyApiClient
|
|
113
120
|
metric_id = parsed_json["metricId"]
|
114
121
|
metric_value = parsed_json["metricValue"]
|
115
122
|
metric_name = parsed_json["metricName"]
|
123
|
+
if parsed_json["currentStreak"].nil?
|
124
|
+
current_streak = nil
|
125
|
+
else
|
126
|
+
current_streak = parsed_json["currentStreak"].to_json
|
127
|
+
current_streak = TrophyApiClient::MetricEventStreakResponse.from_json(json_object: current_streak)
|
128
|
+
end
|
116
129
|
new(
|
117
130
|
completions: completions,
|
118
131
|
completed_percentage: completed_percentage,
|
@@ -126,6 +139,7 @@ module TrophyApiClient
|
|
126
139
|
metric_id: metric_id,
|
127
140
|
metric_value: metric_value,
|
128
141
|
metric_name: metric_name,
|
142
|
+
current_streak: current_streak,
|
129
143
|
additional_properties: struct
|
130
144
|
)
|
131
145
|
end
|
@@ -148,7 +162,7 @@ module TrophyApiClient
|
|
148
162
|
obj.completed_percentage&.is_a?(Float) != false || raise("Passed value for field obj.completed_percentage is not the expected type, validation failed.")
|
149
163
|
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
150
164
|
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
151
|
-
obj.trigger.is_a?(
|
165
|
+
obj.trigger.is_a?(TrophyApiClient::AchievementResponseTrigger) != false || raise("Passed value for field obj.trigger is not the expected type, validation failed.")
|
152
166
|
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
153
167
|
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
154
168
|
obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
@@ -156,6 +170,7 @@ module TrophyApiClient
|
|
156
170
|
obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
|
157
171
|
obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
|
158
172
|
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
173
|
+
obj.current_streak.nil? || TrophyApiClient::MetricEventStreakResponse.validate_raw(obj: obj.current_streak)
|
159
174
|
end
|
160
175
|
end
|
161
176
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "date"
|
4
|
+
require_relative "achievement_response_trigger"
|
5
|
+
require_relative "metric_event_streak_response"
|
4
6
|
require "ostruct"
|
5
7
|
require "json"
|
6
8
|
|
@@ -12,7 +14,7 @@ module TrophyApiClient
|
|
12
14
|
attr_reader :id
|
13
15
|
# @return [String] The name of this achievement.
|
14
16
|
attr_reader :name
|
15
|
-
# @return [
|
17
|
+
# @return [TrophyApiClient::AchievementResponseTrigger] The trigger of the achievement.
|
16
18
|
attr_reader :trigger
|
17
19
|
# @return [String] The description of this achievement.
|
18
20
|
attr_reader :description
|
@@ -33,6 +35,8 @@ module TrophyApiClient
|
|
33
35
|
# @return [String] The name of the metric associated with this achievement (only applicable if
|
34
36
|
# trigger = 'metric')
|
35
37
|
attr_reader :metric_name
|
38
|
+
# @return [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
39
|
+
attr_reader :current_streak
|
36
40
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
37
41
|
attr_reader :additional_properties
|
38
42
|
# @return [Object]
|
@@ -44,7 +48,7 @@ module TrophyApiClient
|
|
44
48
|
# @param achieved_at [DateTime] The date and time the achievement was completed, in ISO 8601 format.
|
45
49
|
# @param id [String] The unique ID of the achievement.
|
46
50
|
# @param name [String] The name of this achievement.
|
47
|
-
# @param trigger [
|
51
|
+
# @param trigger [TrophyApiClient::AchievementResponseTrigger] The trigger of the achievement.
|
48
52
|
# @param description [String] The description of this achievement.
|
49
53
|
# @param badge_url [String] The URL of the badge image for the achievement, if one has been uploaded.
|
50
54
|
# @param key [String] The key used to reference this achievement in the API (only applicable if
|
@@ -57,10 +61,11 @@ module TrophyApiClient
|
|
57
61
|
# trigger = 'metric')
|
58
62
|
# @param metric_name [String] The name of the metric associated with this achievement (only applicable if
|
59
63
|
# trigger = 'metric')
|
64
|
+
# @param current_streak [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
60
65
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
61
66
|
# @return [TrophyApiClient::CompletedAchievementResponse]
|
62
67
|
def initialize(id:, name:, trigger:, achieved_at: OMIT, description: OMIT, badge_url: OMIT, key: OMIT,
|
63
|
-
streak_length: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, additional_properties: nil)
|
68
|
+
streak_length: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, current_streak: OMIT, additional_properties: nil)
|
64
69
|
@achieved_at = achieved_at if achieved_at != OMIT
|
65
70
|
@id = id
|
66
71
|
@name = name
|
@@ -72,6 +77,7 @@ module TrophyApiClient
|
|
72
77
|
@metric_id = metric_id if metric_id != OMIT
|
73
78
|
@metric_value = metric_value if metric_value != OMIT
|
74
79
|
@metric_name = metric_name if metric_name != OMIT
|
80
|
+
@current_streak = current_streak if current_streak != OMIT
|
75
81
|
@additional_properties = additional_properties
|
76
82
|
@_field_set = {
|
77
83
|
"achievedAt": achieved_at,
|
@@ -84,7 +90,8 @@ module TrophyApiClient
|
|
84
90
|
"streakLength": streak_length,
|
85
91
|
"metricId": metric_id,
|
86
92
|
"metricValue": metric_value,
|
87
|
-
"metricName": metric_name
|
93
|
+
"metricName": metric_name,
|
94
|
+
"currentStreak": current_streak
|
88
95
|
}.reject do |_k, v|
|
89
96
|
v == OMIT
|
90
97
|
end
|
@@ -108,6 +115,12 @@ module TrophyApiClient
|
|
108
115
|
metric_id = parsed_json["metricId"]
|
109
116
|
metric_value = parsed_json["metricValue"]
|
110
117
|
metric_name = parsed_json["metricName"]
|
118
|
+
if parsed_json["currentStreak"].nil?
|
119
|
+
current_streak = nil
|
120
|
+
else
|
121
|
+
current_streak = parsed_json["currentStreak"].to_json
|
122
|
+
current_streak = TrophyApiClient::MetricEventStreakResponse.from_json(json_object: current_streak)
|
123
|
+
end
|
111
124
|
new(
|
112
125
|
achieved_at: achieved_at,
|
113
126
|
id: id,
|
@@ -120,6 +133,7 @@ module TrophyApiClient
|
|
120
133
|
metric_id: metric_id,
|
121
134
|
metric_value: metric_value,
|
122
135
|
metric_name: metric_name,
|
136
|
+
current_streak: current_streak,
|
123
137
|
additional_properties: struct
|
124
138
|
)
|
125
139
|
end
|
@@ -141,7 +155,7 @@ module TrophyApiClient
|
|
141
155
|
obj.achieved_at&.is_a?(DateTime) != false || raise("Passed value for field obj.achieved_at is not the expected type, validation failed.")
|
142
156
|
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
143
157
|
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
144
|
-
obj.trigger.is_a?(
|
158
|
+
obj.trigger.is_a?(TrophyApiClient::AchievementResponseTrigger) != false || raise("Passed value for field obj.trigger is not the expected type, validation failed.")
|
145
159
|
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
146
160
|
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
147
161
|
obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
@@ -149,6 +163,7 @@ module TrophyApiClient
|
|
149
163
|
obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
|
150
164
|
obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
|
151
165
|
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
166
|
+
obj.current_streak.nil? || TrophyApiClient::MetricEventStreakResponse.validate_raw(obj: obj.current_streak)
|
152
167
|
end
|
153
168
|
end
|
154
169
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "completed_achievement_response"
|
4
|
-
require_relative "
|
4
|
+
require_relative "metric_event_streak_response"
|
5
|
+
require_relative "points_award"
|
5
6
|
require "ostruct"
|
6
7
|
require "json"
|
7
8
|
|
@@ -15,8 +16,11 @@ module TrophyApiClient
|
|
15
16
|
attr_reader :total
|
16
17
|
# @return [Array<TrophyApiClient::CompletedAchievementResponse>] Achievements completed as a result of this event.
|
17
18
|
attr_reader :achievements
|
18
|
-
# @return [TrophyApiClient::
|
19
|
+
# @return [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
19
20
|
attr_reader :current_streak
|
21
|
+
# @return [TrophyApiClient::PointsAward] The points added by this event, and a breakdown of the points awards that added
|
22
|
+
# points.
|
23
|
+
attr_reader :points
|
20
24
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
21
25
|
attr_reader :additional_properties
|
22
26
|
# @return [Object]
|
@@ -29,22 +33,27 @@ module TrophyApiClient
|
|
29
33
|
# @param metric_id [String] The unique ID of the metric that was updated.
|
30
34
|
# @param total [Float] The user's new total progress against the metric.
|
31
35
|
# @param achievements [Array<TrophyApiClient::CompletedAchievementResponse>] Achievements completed as a result of this event.
|
32
|
-
# @param current_streak [TrophyApiClient::
|
36
|
+
# @param current_streak [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
37
|
+
# @param points [TrophyApiClient::PointsAward] The points added by this event, and a breakdown of the points awards that added
|
38
|
+
# points.
|
33
39
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
34
40
|
# @return [TrophyApiClient::EventResponse]
|
35
|
-
def initialize(event_id:, metric_id:, total:, achievements: OMIT, current_streak: OMIT,
|
41
|
+
def initialize(event_id:, metric_id:, total:, achievements: OMIT, current_streak: OMIT, points: OMIT,
|
42
|
+
additional_properties: nil)
|
36
43
|
@event_id = event_id
|
37
44
|
@metric_id = metric_id
|
38
45
|
@total = total
|
39
46
|
@achievements = achievements if achievements != OMIT
|
40
47
|
@current_streak = current_streak if current_streak != OMIT
|
48
|
+
@points = points if points != OMIT
|
41
49
|
@additional_properties = additional_properties
|
42
50
|
@_field_set = {
|
43
51
|
"eventId": event_id,
|
44
52
|
"metricId": metric_id,
|
45
53
|
"total": total,
|
46
54
|
"achievements": achievements,
|
47
|
-
"currentStreak": current_streak
|
55
|
+
"currentStreak": current_streak,
|
56
|
+
"points": points
|
48
57
|
}.reject do |_k, v|
|
49
58
|
v == OMIT
|
50
59
|
end
|
@@ -68,7 +77,13 @@ module TrophyApiClient
|
|
68
77
|
current_streak = nil
|
69
78
|
else
|
70
79
|
current_streak = parsed_json["currentStreak"].to_json
|
71
|
-
current_streak = TrophyApiClient::
|
80
|
+
current_streak = TrophyApiClient::MetricEventStreakResponse.from_json(json_object: current_streak)
|
81
|
+
end
|
82
|
+
if parsed_json["points"].nil?
|
83
|
+
points = nil
|
84
|
+
else
|
85
|
+
points = parsed_json["points"].to_json
|
86
|
+
points = TrophyApiClient::PointsAward.from_json(json_object: points)
|
72
87
|
end
|
73
88
|
new(
|
74
89
|
event_id: event_id,
|
@@ -76,6 +91,7 @@ module TrophyApiClient
|
|
76
91
|
total: total,
|
77
92
|
achievements: achievements,
|
78
93
|
current_streak: current_streak,
|
94
|
+
points: points,
|
79
95
|
additional_properties: struct
|
80
96
|
)
|
81
97
|
end
|
@@ -98,7 +114,8 @@ module TrophyApiClient
|
|
98
114
|
obj.metric_id.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
|
99
115
|
obj.total.is_a?(Float) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
|
100
116
|
obj.achievements&.is_a?(Array) != false || raise("Passed value for field obj.achievements is not the expected type, validation failed.")
|
101
|
-
obj.current_streak.nil? || TrophyApiClient::
|
117
|
+
obj.current_streak.nil? || TrophyApiClient::MetricEventStreakResponse.validate_raw(obj: obj.current_streak)
|
118
|
+
obj.points.nil? || TrophyApiClient::PointsAward.validate_raw(obj: obj.points)
|
102
119
|
end
|
103
120
|
end
|
104
121
|
end
|