trophy_api_client 1.0.9 → 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/achievements/client.rb +79 -7
- data/lib/trophy_api_client/points/client.rb +175 -0
- data/lib/trophy_api_client/types/achievement_completion_response.rb +5 -5
- data/lib/trophy_api_client/types/achievement_response.rb +29 -15
- data/lib/trophy_api_client/types/achievement_response_trigger.rb +10 -0
- data/lib/trophy_api_client/types/achievement_with_stats_response.rb +176 -0
- data/lib/trophy_api_client/types/completed_achievement_response.rb +169 -0
- data/lib/trophy_api_client/types/event_response.rb +28 -11
- 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/metric_response.rb +4 -4
- 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 +278 -5
- data/lib/trophy_api_client/users/types/users_metric_event_summary_request_aggregation.rb +11 -0
- data/lib/trophy_api_client/users/types/users_metric_event_summary_response_item.rb +76 -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 +18 -1
- metadata +20 -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
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "../../requests"
|
4
|
-
require_relative "../types/
|
4
|
+
require_relative "../types/achievement_with_stats_response"
|
5
|
+
require "json"
|
6
|
+
require_relative "../types/updated_user"
|
5
7
|
require_relative "../types/achievement_completion_response"
|
6
8
|
require "async"
|
7
9
|
|
@@ -16,11 +18,45 @@ module TrophyApiClient
|
|
16
18
|
@request_client = request_client
|
17
19
|
end
|
18
20
|
|
21
|
+
# Get all achievements and their completion stats.
|
22
|
+
#
|
23
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
24
|
+
# @return [Array<TrophyApiClient::AchievementWithStatsResponse>]
|
25
|
+
# @example
|
26
|
+
# api = TrophyApiClient::Client.new(
|
27
|
+
# base_url: "https://api.example.com",
|
28
|
+
# environment: TrophyApiClient::Environment::DEFAULT,
|
29
|
+
# api_key: "YOUR_API_KEY"
|
30
|
+
# )
|
31
|
+
# api.achievements.all
|
32
|
+
def all(request_options: nil)
|
33
|
+
response = @request_client.conn.get do |req|
|
34
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
35
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
36
|
+
req.headers = {
|
37
|
+
**(req.headers || {}),
|
38
|
+
**@request_client.get_headers,
|
39
|
+
**(request_options&.additional_headers || {})
|
40
|
+
}.compact
|
41
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
42
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
43
|
+
end
|
44
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
45
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
46
|
+
end
|
47
|
+
req.url "#{@request_client.get_url(request_options: request_options)}/achievements"
|
48
|
+
end
|
49
|
+
parsed_json = JSON.parse(response.body)
|
50
|
+
parsed_json&.map do |item|
|
51
|
+
item = item.to_json
|
52
|
+
TrophyApiClient::AchievementWithStatsResponse.from_json(json_object: item)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
19
56
|
# Mark an achievement as completed for a user.
|
20
57
|
#
|
21
58
|
# @param key [String] Unique reference of the achievement as set when created.
|
22
|
-
# @param user [Hash] The user that completed the achievement.Request of type TrophyApiClient::
|
23
|
-
# * :id (String)
|
59
|
+
# @param user [Hash] The user that completed the achievement.Request of type TrophyApiClient::UpdatedUser, as a Hash
|
24
60
|
# * :email (String)
|
25
61
|
# * :name (String)
|
26
62
|
# * :tz (String)
|
@@ -33,7 +69,7 @@ module TrophyApiClient
|
|
33
69
|
# environment: TrophyApiClient::Environment::DEFAULT,
|
34
70
|
# api_key: "YOUR_API_KEY"
|
35
71
|
# )
|
36
|
-
# api.achievements.complete(key: "finish-onboarding", user: {
|
72
|
+
# api.achievements.complete(key: "finish-onboarding", user: { email: "user@example.com", tz: "Europe/London" })
|
37
73
|
def complete(key:, user:, request_options: nil)
|
38
74
|
response = @request_client.conn.post do |req|
|
39
75
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
@@ -63,11 +99,47 @@ module TrophyApiClient
|
|
63
99
|
@request_client = request_client
|
64
100
|
end
|
65
101
|
|
102
|
+
# Get all achievements and their completion stats.
|
103
|
+
#
|
104
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
105
|
+
# @return [Array<TrophyApiClient::AchievementWithStatsResponse>]
|
106
|
+
# @example
|
107
|
+
# api = TrophyApiClient::Client.new(
|
108
|
+
# base_url: "https://api.example.com",
|
109
|
+
# environment: TrophyApiClient::Environment::DEFAULT,
|
110
|
+
# api_key: "YOUR_API_KEY"
|
111
|
+
# )
|
112
|
+
# api.achievements.all
|
113
|
+
def all(request_options: nil)
|
114
|
+
Async do
|
115
|
+
response = @request_client.conn.get do |req|
|
116
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
117
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
118
|
+
req.headers = {
|
119
|
+
**(req.headers || {}),
|
120
|
+
**@request_client.get_headers,
|
121
|
+
**(request_options&.additional_headers || {})
|
122
|
+
}.compact
|
123
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
124
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
125
|
+
end
|
126
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
127
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
128
|
+
end
|
129
|
+
req.url "#{@request_client.get_url(request_options: request_options)}/achievements"
|
130
|
+
end
|
131
|
+
parsed_json = JSON.parse(response.body)
|
132
|
+
parsed_json&.map do |item|
|
133
|
+
item = item.to_json
|
134
|
+
TrophyApiClient::AchievementWithStatsResponse.from_json(json_object: item)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
66
139
|
# Mark an achievement as completed for a user.
|
67
140
|
#
|
68
141
|
# @param key [String] Unique reference of the achievement as set when created.
|
69
|
-
# @param user [Hash] The user that completed the achievement.Request of type TrophyApiClient::
|
70
|
-
# * :id (String)
|
142
|
+
# @param user [Hash] The user that completed the achievement.Request of type TrophyApiClient::UpdatedUser, as a Hash
|
71
143
|
# * :email (String)
|
72
144
|
# * :name (String)
|
73
145
|
# * :tz (String)
|
@@ -80,7 +152,7 @@ module TrophyApiClient
|
|
80
152
|
# environment: TrophyApiClient::Environment::DEFAULT,
|
81
153
|
# api_key: "YOUR_API_KEY"
|
82
154
|
# )
|
83
|
-
# api.achievements.complete(key: "finish-onboarding", user: {
|
155
|
+
# api.achievements.complete(key: "finish-onboarding", user: { email: "user@example.com", tz: "Europe/London" })
|
84
156
|
def complete(key:, user:, request_options: nil)
|
85
157
|
Async do
|
86
158
|
response = @request_client.conn.post do |req|
|
@@ -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,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "
|
3
|
+
require_relative "completed_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::CompletedAchievementResponse]
|
12
12
|
attr_reader :achievement
|
13
13
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
14
14
|
attr_reader :additional_properties
|
@@ -19,7 +19,7 @@ module TrophyApiClient
|
|
19
19
|
OMIT = Object.new
|
20
20
|
|
21
21
|
# @param completion_id [String] The unique ID of the completion.
|
22
|
-
# @param achievement [TrophyApiClient::
|
22
|
+
# @param achievement [TrophyApiClient::CompletedAchievementResponse]
|
23
23
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
24
24
|
# @return [TrophyApiClient::AchievementCompletionResponse]
|
25
25
|
def initialize(completion_id:, achievement:, additional_properties: nil)
|
@@ -41,7 +41,7 @@ module TrophyApiClient
|
|
41
41
|
achievement = nil
|
42
42
|
else
|
43
43
|
achievement = parsed_json["achievement"].to_json
|
44
|
-
achievement = TrophyApiClient::
|
44
|
+
achievement = TrophyApiClient::CompletedAchievementResponse.from_json(json_object: achievement)
|
45
45
|
end
|
46
46
|
new(
|
47
47
|
completion_id: completion_id,
|
@@ -65,7 +65,7 @@ module TrophyApiClient
|
|
65
65
|
# @return [Void]
|
66
66
|
def self.validate_raw(obj:)
|
67
67
|
obj.completion_id.is_a?(String) != false || raise("Passed value for field obj.completion_id is not the expected type, validation failed.")
|
68
|
-
TrophyApiClient::
|
68
|
+
TrophyApiClient::CompletedAchievementResponse.validate_raw(obj: obj.achievement)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative "achievement_response_trigger"
|
4
|
+
require_relative "metric_event_streak_response"
|
4
5
|
require "ostruct"
|
5
6
|
require "json"
|
6
7
|
|
@@ -10,12 +11,12 @@ module TrophyApiClient
|
|
10
11
|
attr_reader :id
|
11
12
|
# @return [String] The name of this achievement.
|
12
13
|
attr_reader :name
|
13
|
-
# @return [
|
14
|
+
# @return [TrophyApiClient::AchievementResponseTrigger] The trigger of the achievement.
|
14
15
|
attr_reader :trigger
|
16
|
+
# @return [String] The description of this achievement.
|
17
|
+
attr_reader :description
|
15
18
|
# @return [String] The URL of the badge image for the achievement, if one has been uploaded.
|
16
19
|
attr_reader :badge_url
|
17
|
-
# @return [DateTime] The date and time the achievement was completed, in ISO 8601 format.
|
18
|
-
attr_reader :achieved_at
|
19
20
|
# @return [String] The key used to reference this achievement in the API (only applicable if
|
20
21
|
# trigger = 'api')
|
21
22
|
attr_reader :key
|
@@ -31,6 +32,8 @@ module TrophyApiClient
|
|
31
32
|
# @return [String] The name of the metric associated with this achievement (only applicable if
|
32
33
|
# trigger = 'metric')
|
33
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
|
34
37
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
35
38
|
attr_reader :additional_properties
|
36
39
|
# @return [Object]
|
@@ -41,9 +44,9 @@ module TrophyApiClient
|
|
41
44
|
|
42
45
|
# @param id [String] The unique ID of the achievement.
|
43
46
|
# @param name [String] The name of this achievement.
|
44
|
-
# @param trigger [
|
47
|
+
# @param trigger [TrophyApiClient::AchievementResponseTrigger] The trigger of the achievement.
|
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
|
-
# @param achieved_at [DateTime] The date and time the achievement was completed, in ISO 8601 format.
|
47
50
|
# @param key [String] The key used to reference this achievement in the API (only applicable if
|
48
51
|
# trigger = 'api')
|
49
52
|
# @param streak_length [Integer] The length of the streak required to complete the achievement (only applicable
|
@@ -54,32 +57,35 @@ module TrophyApiClient
|
|
54
57
|
# trigger = 'metric')
|
55
58
|
# @param metric_name [String] The name of the metric associated with this achievement (only applicable if
|
56
59
|
# trigger = 'metric')
|
60
|
+
# @param current_streak [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
57
61
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
58
62
|
# @return [TrophyApiClient::AchievementResponse]
|
59
|
-
def initialize(id:, name:, trigger:,
|
60
|
-
metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, additional_properties: nil)
|
63
|
+
def initialize(id:, name:, trigger:, description: OMIT, badge_url: OMIT, key: OMIT, streak_length: OMIT,
|
64
|
+
metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, current_streak: OMIT, additional_properties: nil)
|
61
65
|
@id = id
|
62
66
|
@name = name
|
63
67
|
@trigger = trigger
|
68
|
+
@description = description if description != OMIT
|
64
69
|
@badge_url = badge_url if badge_url != OMIT
|
65
|
-
@achieved_at = achieved_at if achieved_at != OMIT
|
66
70
|
@key = key if key != OMIT
|
67
71
|
@streak_length = streak_length if streak_length != OMIT
|
68
72
|
@metric_id = metric_id if metric_id != OMIT
|
69
73
|
@metric_value = metric_value if metric_value != OMIT
|
70
74
|
@metric_name = metric_name if metric_name != OMIT
|
75
|
+
@current_streak = current_streak if current_streak != OMIT
|
71
76
|
@additional_properties = additional_properties
|
72
77
|
@_field_set = {
|
73
78
|
"id": id,
|
74
79
|
"name": name,
|
75
80
|
"trigger": trigger,
|
81
|
+
"description": description,
|
76
82
|
"badgeUrl": badge_url,
|
77
|
-
"achievedAt": achieved_at,
|
78
83
|
"key": key,
|
79
84
|
"streakLength": streak_length,
|
80
85
|
"metricId": metric_id,
|
81
86
|
"metricValue": metric_value,
|
82
|
-
"metricName": metric_name
|
87
|
+
"metricName": metric_name,
|
88
|
+
"currentStreak": current_streak
|
83
89
|
}.reject do |_k, v|
|
84
90
|
v == OMIT
|
85
91
|
end
|
@@ -95,24 +101,31 @@ module TrophyApiClient
|
|
95
101
|
id = parsed_json["id"]
|
96
102
|
name = parsed_json["name"]
|
97
103
|
trigger = parsed_json["trigger"]
|
104
|
+
description = parsed_json["description"]
|
98
105
|
badge_url = parsed_json["badgeUrl"]
|
99
|
-
achieved_at = (DateTime.parse(parsed_json["achievedAt"]) unless parsed_json["achievedAt"].nil?)
|
100
106
|
key = parsed_json["key"]
|
101
107
|
streak_length = parsed_json["streakLength"]
|
102
108
|
metric_id = parsed_json["metricId"]
|
103
109
|
metric_value = parsed_json["metricValue"]
|
104
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
|
105
117
|
new(
|
106
118
|
id: id,
|
107
119
|
name: name,
|
108
120
|
trigger: trigger,
|
121
|
+
description: description,
|
109
122
|
badge_url: badge_url,
|
110
|
-
achieved_at: achieved_at,
|
111
123
|
key: key,
|
112
124
|
streak_length: streak_length,
|
113
125
|
metric_id: metric_id,
|
114
126
|
metric_value: metric_value,
|
115
127
|
metric_name: metric_name,
|
128
|
+
current_streak: current_streak,
|
116
129
|
additional_properties: struct
|
117
130
|
)
|
118
131
|
end
|
@@ -133,14 +146,15 @@ module TrophyApiClient
|
|
133
146
|
def self.validate_raw(obj:)
|
134
147
|
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
135
148
|
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
136
|
-
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.")
|
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
|
-
obj.achieved_at&.is_a?(DateTime) != false || raise("Passed value for field obj.achieved_at is not the expected type, validation failed.")
|
139
152
|
obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
140
153
|
obj.streak_length&.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.")
|
141
154
|
obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
|
142
155
|
obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
|
143
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)
|
144
158
|
end
|
145
159
|
end
|
146
160
|
end
|