trophy_api_client 1.1.2 → 1.2.1
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 +152 -0
- data/lib/trophy_api_client/types/get_user_points_response.rb +38 -22
- data/lib/trophy_api_client/types/metric_event_points_response.rb +47 -31
- data/lib/trophy_api_client/types/points_level.rb +103 -0
- data/lib/trophy_api_client/types/points_level_summary_response.rb +7 -0
- data/lib/trophy_api_client/types/points_level_summary_response_item.rb +71 -0
- data/lib/trophy_api_client/types/points_response.rb +103 -0
- data/lib/trophy_api_client/types/webhooks_points_level_changed_payload.rb +117 -0
- data/lib/trophy_api_client/types/webhooks_points_level_changed_payload_points.rb +114 -0
- data/lib/trophy_api_client/version.rb +1 -1
- data/lib/types_export.rb +6 -0
- metadata +8 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 74ccdc4a3dcbe88ed2254ca474165644225960617b4e4498f7deec3db6e209bc
|
|
4
|
+
data.tar.gz: 5f3cc5a4aa340463de78a5cdad7f043e56960cd5a9cdf50eb03c86934549d7e3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d9176a0b52777a98068243e21bf0d891fe3035b3643cb54dc9514f359c4198186197492fef8b664e911b5dba3b8d81c2f66c11501a23270a653919fa3dd500bb
|
|
7
|
+
data.tar.gz: 9b870ec63aa0b1cf14cd716ed095f0b252672b415f6d11ff992cb948867059794f216c8b0dd5e28d3da2c4ae33e1e569d1e31a59dc124d36159e70e00db51259
|
data/lib/gemconfig.rb
CHANGED
|
@@ -5,6 +5,8 @@ require_relative "../types/points_summary_response"
|
|
|
5
5
|
require "json"
|
|
6
6
|
require_relative "../types/points_system_response"
|
|
7
7
|
require_relative "../types/points_boost"
|
|
8
|
+
require_relative "../types/points_level"
|
|
9
|
+
require_relative "../types/points_level_summary_response"
|
|
8
10
|
require "async"
|
|
9
11
|
|
|
10
12
|
module TrophyApiClient
|
|
@@ -129,6 +131,79 @@ module TrophyApiClient
|
|
|
129
131
|
TrophyApiClient::PointsBoost.from_json(json_object: item)
|
|
130
132
|
end
|
|
131
133
|
end
|
|
134
|
+
|
|
135
|
+
# Get all levels for a points system.
|
|
136
|
+
#
|
|
137
|
+
# @param key [String] Key of the points system.
|
|
138
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
139
|
+
# @return [Array<TrophyApiClient::PointsLevel>]
|
|
140
|
+
# @example
|
|
141
|
+
# api = TrophyApiClient::Client.new(
|
|
142
|
+
# base_url: "https://api.example.com",
|
|
143
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
144
|
+
# api_key: "YOUR_API_KEY"
|
|
145
|
+
# )
|
|
146
|
+
# api.points.levels(key: "points-system-key")
|
|
147
|
+
def levels(key:, request_options: nil)
|
|
148
|
+
response = @request_client.conn.get do |req|
|
|
149
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
150
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
151
|
+
req.headers = {
|
|
152
|
+
**(req.headers || {}),
|
|
153
|
+
**@request_client.get_headers,
|
|
154
|
+
**(request_options&.additional_headers || {})
|
|
155
|
+
}.compact
|
|
156
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
157
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
158
|
+
end
|
|
159
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
160
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
161
|
+
end
|
|
162
|
+
req.url "#{@request_client.get_url(environment: api, request_options: request_options)}/points/#{key}/levels"
|
|
163
|
+
end
|
|
164
|
+
parsed_json = JSON.parse(response.body)
|
|
165
|
+
parsed_json&.map do |item|
|
|
166
|
+
item = item.to_json
|
|
167
|
+
TrophyApiClient::PointsLevel.from_json(json_object: item)
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Get a breakdown of the number of users at each level in a points system.
|
|
172
|
+
#
|
|
173
|
+
# @param key [String] Key of the points system.
|
|
174
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
175
|
+
# @return [TrophyApiClient::POINTS_LEVEL_SUMMARY_RESPONSE]
|
|
176
|
+
# @example
|
|
177
|
+
# api = TrophyApiClient::Client.new(
|
|
178
|
+
# base_url: "https://api.example.com",
|
|
179
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
180
|
+
# api_key: "YOUR_API_KEY"
|
|
181
|
+
# )
|
|
182
|
+
# api.points.level_summary(key: "points-system-key")
|
|
183
|
+
def level_summary(key:, request_options: nil)
|
|
184
|
+
response = @request_client.conn.get do |req|
|
|
185
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
186
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
187
|
+
req.headers = {
|
|
188
|
+
**(req.headers || {}),
|
|
189
|
+
**@request_client.get_headers,
|
|
190
|
+
**(request_options&.additional_headers || {})
|
|
191
|
+
}.compact
|
|
192
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
193
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
194
|
+
end
|
|
195
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
196
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
197
|
+
end
|
|
198
|
+
req.url "#{@request_client.get_url(environment: api,
|
|
199
|
+
request_options: request_options)}/points/#{key}/level-summary"
|
|
200
|
+
end
|
|
201
|
+
parsed_json = JSON.parse(response.body)
|
|
202
|
+
parsed_json&.map do |item|
|
|
203
|
+
item = item.to_json
|
|
204
|
+
TrophyApiClient::PointsLevelSummaryResponseItem.from_json(json_object: item)
|
|
205
|
+
end
|
|
206
|
+
end
|
|
132
207
|
end
|
|
133
208
|
|
|
134
209
|
class AsyncPointsClient
|
|
@@ -258,5 +333,82 @@ module TrophyApiClient
|
|
|
258
333
|
end
|
|
259
334
|
end
|
|
260
335
|
end
|
|
336
|
+
|
|
337
|
+
# Get all levels for a points system.
|
|
338
|
+
#
|
|
339
|
+
# @param key [String] Key of the points system.
|
|
340
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
341
|
+
# @return [Array<TrophyApiClient::PointsLevel>]
|
|
342
|
+
# @example
|
|
343
|
+
# api = TrophyApiClient::Client.new(
|
|
344
|
+
# base_url: "https://api.example.com",
|
|
345
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
346
|
+
# api_key: "YOUR_API_KEY"
|
|
347
|
+
# )
|
|
348
|
+
# api.points.levels(key: "points-system-key")
|
|
349
|
+
def levels(key:, request_options: nil)
|
|
350
|
+
Async do
|
|
351
|
+
response = @request_client.conn.get do |req|
|
|
352
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
353
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
354
|
+
req.headers = {
|
|
355
|
+
**(req.headers || {}),
|
|
356
|
+
**@request_client.get_headers,
|
|
357
|
+
**(request_options&.additional_headers || {})
|
|
358
|
+
}.compact
|
|
359
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
360
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
361
|
+
end
|
|
362
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
363
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
364
|
+
end
|
|
365
|
+
req.url "#{@request_client.get_url(environment: api, request_options: request_options)}/points/#{key}/levels"
|
|
366
|
+
end
|
|
367
|
+
parsed_json = JSON.parse(response.body)
|
|
368
|
+
parsed_json&.map do |item|
|
|
369
|
+
item = item.to_json
|
|
370
|
+
TrophyApiClient::PointsLevel.from_json(json_object: item)
|
|
371
|
+
end
|
|
372
|
+
end
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
# Get a breakdown of the number of users at each level in a points system.
|
|
376
|
+
#
|
|
377
|
+
# @param key [String] Key of the points system.
|
|
378
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
|
379
|
+
# @return [TrophyApiClient::POINTS_LEVEL_SUMMARY_RESPONSE]
|
|
380
|
+
# @example
|
|
381
|
+
# api = TrophyApiClient::Client.new(
|
|
382
|
+
# base_url: "https://api.example.com",
|
|
383
|
+
# environment: TrophyApiClient::Environment::PRODUCTION,
|
|
384
|
+
# api_key: "YOUR_API_KEY"
|
|
385
|
+
# )
|
|
386
|
+
# api.points.level_summary(key: "points-system-key")
|
|
387
|
+
def level_summary(key:, request_options: nil)
|
|
388
|
+
Async do
|
|
389
|
+
response = @request_client.conn.get do |req|
|
|
390
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
|
391
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
|
392
|
+
req.headers = {
|
|
393
|
+
**(req.headers || {}),
|
|
394
|
+
**@request_client.get_headers,
|
|
395
|
+
**(request_options&.additional_headers || {})
|
|
396
|
+
}.compact
|
|
397
|
+
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
|
398
|
+
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
|
399
|
+
end
|
|
400
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
|
401
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
|
402
|
+
end
|
|
403
|
+
req.url "#{@request_client.get_url(environment: api,
|
|
404
|
+
request_options: request_options)}/points/#{key}/level-summary"
|
|
405
|
+
end
|
|
406
|
+
parsed_json = JSON.parse(response.body)
|
|
407
|
+
parsed_json&.map do |item|
|
|
408
|
+
item = item.to_json
|
|
409
|
+
TrophyApiClient::PointsLevelSummaryResponseItem.from_json(json_object: item)
|
|
410
|
+
end
|
|
411
|
+
end
|
|
412
|
+
end
|
|
261
413
|
end
|
|
262
414
|
end
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "points_level"
|
|
3
4
|
require_relative "points_award"
|
|
4
5
|
require "ostruct"
|
|
5
6
|
require "json"
|
|
6
7
|
|
|
7
8
|
module TrophyApiClient
|
|
8
9
|
class GetUserPointsResponse
|
|
10
|
+
# @return [Integer] The user's total points
|
|
11
|
+
attr_reader :total
|
|
12
|
+
# @return [TrophyApiClient::PointsLevel] The user's current level in this points system, or null if no levels are
|
|
13
|
+
# configured or the user hasn't reached any level yet.
|
|
14
|
+
attr_reader :level
|
|
15
|
+
# @return [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
|
16
|
+
attr_reader :awards
|
|
9
17
|
# @return [String] The ID of the points system
|
|
10
18
|
attr_reader :id
|
|
11
19
|
# @return [String] The key of the points system
|
|
@@ -18,10 +26,6 @@ module TrophyApiClient
|
|
|
18
26
|
attr_reader :badge_url
|
|
19
27
|
# @return [Float] The maximum number of points a user can be awarded in this points system
|
|
20
28
|
attr_reader :max_points
|
|
21
|
-
# @return [Integer] The user's total points
|
|
22
|
-
attr_reader :total
|
|
23
|
-
# @return [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
|
24
|
-
attr_reader :awards
|
|
25
29
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
26
30
|
attr_reader :additional_properties
|
|
27
31
|
# @return [Object]
|
|
@@ -30,36 +34,40 @@ module TrophyApiClient
|
|
|
30
34
|
|
|
31
35
|
OMIT = Object.new
|
|
32
36
|
|
|
37
|
+
# @param total [Integer] The user's total points
|
|
38
|
+
# @param level [TrophyApiClient::PointsLevel] The user's current level in this points system, or null if no levels are
|
|
39
|
+
# configured or the user hasn't reached any level yet.
|
|
40
|
+
# @param awards [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
|
33
41
|
# @param id [String] The ID of the points system
|
|
34
42
|
# @param key [String] The key of the points system
|
|
35
43
|
# @param name [String] The name of the points system
|
|
36
44
|
# @param description [String] The description of the points system
|
|
37
45
|
# @param badge_url [String] The URL of the badge image for the points system
|
|
38
46
|
# @param max_points [Float] The maximum number of points a user can be awarded in this points system
|
|
39
|
-
# @param total [Integer] The user's total points
|
|
40
|
-
# @param awards [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
|
41
47
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
42
48
|
# @return [TrophyApiClient::GetUserPointsResponse]
|
|
43
|
-
def initialize(
|
|
44
|
-
additional_properties: nil)
|
|
49
|
+
def initialize(total:, awards:, id:, key:, name:, level: OMIT, description: OMIT, badge_url: OMIT,
|
|
50
|
+
max_points: OMIT, additional_properties: nil)
|
|
51
|
+
@total = total
|
|
52
|
+
@level = level if level != OMIT
|
|
53
|
+
@awards = awards
|
|
45
54
|
@id = id
|
|
46
55
|
@key = key
|
|
47
56
|
@name = name
|
|
48
57
|
@description = description if description != OMIT
|
|
49
58
|
@badge_url = badge_url if badge_url != OMIT
|
|
50
59
|
@max_points = max_points if max_points != OMIT
|
|
51
|
-
@total = total
|
|
52
|
-
@awards = awards
|
|
53
60
|
@additional_properties = additional_properties
|
|
54
61
|
@_field_set = {
|
|
62
|
+
"total": total,
|
|
63
|
+
"level": level,
|
|
64
|
+
"awards": awards,
|
|
55
65
|
"id": id,
|
|
56
66
|
"key": key,
|
|
57
67
|
"name": name,
|
|
58
68
|
"description": description,
|
|
59
69
|
"badgeUrl": badge_url,
|
|
60
|
-
"maxPoints": max_points
|
|
61
|
-
"total": total,
|
|
62
|
-
"awards": awards
|
|
70
|
+
"maxPoints": max_points
|
|
63
71
|
}.reject do |_k, v|
|
|
64
72
|
v == OMIT
|
|
65
73
|
end
|
|
@@ -72,26 +80,33 @@ module TrophyApiClient
|
|
|
72
80
|
def self.from_json(json_object:)
|
|
73
81
|
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
74
82
|
parsed_json = JSON.parse(json_object)
|
|
83
|
+
total = parsed_json["total"]
|
|
84
|
+
if parsed_json["level"].nil?
|
|
85
|
+
level = nil
|
|
86
|
+
else
|
|
87
|
+
level = parsed_json["level"].to_json
|
|
88
|
+
level = TrophyApiClient::PointsLevel.from_json(json_object: level)
|
|
89
|
+
end
|
|
90
|
+
awards = parsed_json["awards"]&.map do |item|
|
|
91
|
+
item = item.to_json
|
|
92
|
+
TrophyApiClient::PointsAward.from_json(json_object: item)
|
|
93
|
+
end
|
|
75
94
|
id = parsed_json["id"]
|
|
76
95
|
key = parsed_json["key"]
|
|
77
96
|
name = parsed_json["name"]
|
|
78
97
|
description = parsed_json["description"]
|
|
79
98
|
badge_url = parsed_json["badgeUrl"]
|
|
80
99
|
max_points = parsed_json["maxPoints"]
|
|
81
|
-
total = parsed_json["total"]
|
|
82
|
-
awards = parsed_json["awards"]&.map do |item|
|
|
83
|
-
item = item.to_json
|
|
84
|
-
TrophyApiClient::PointsAward.from_json(json_object: item)
|
|
85
|
-
end
|
|
86
100
|
new(
|
|
101
|
+
total: total,
|
|
102
|
+
level: level,
|
|
103
|
+
awards: awards,
|
|
87
104
|
id: id,
|
|
88
105
|
key: key,
|
|
89
106
|
name: name,
|
|
90
107
|
description: description,
|
|
91
108
|
badge_url: badge_url,
|
|
92
109
|
max_points: max_points,
|
|
93
|
-
total: total,
|
|
94
|
-
awards: awards,
|
|
95
110
|
additional_properties: struct
|
|
96
111
|
)
|
|
97
112
|
end
|
|
@@ -110,14 +125,15 @@ module TrophyApiClient
|
|
|
110
125
|
# @param obj [Object]
|
|
111
126
|
# @return [Void]
|
|
112
127
|
def self.validate_raw(obj:)
|
|
128
|
+
obj.total.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
|
|
129
|
+
obj.level.nil? || TrophyApiClient::PointsLevel.validate_raw(obj: obj.level)
|
|
130
|
+
obj.awards.is_a?(Array) != false || raise("Passed value for field obj.awards is not the expected type, validation failed.")
|
|
113
131
|
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
|
114
132
|
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
115
133
|
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
116
134
|
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
|
117
135
|
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
|
118
136
|
obj.max_points&.is_a?(Float) != false || raise("Passed value for field obj.max_points is not the expected type, validation failed.")
|
|
119
|
-
obj.total.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
|
|
120
|
-
obj.awards.is_a?(Array) != false || raise("Passed value for field obj.awards is not the expected type, validation failed.")
|
|
121
137
|
end
|
|
122
138
|
end
|
|
123
139
|
end
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "points_level"
|
|
3
4
|
require_relative "points_award"
|
|
4
5
|
require "ostruct"
|
|
5
6
|
require "json"
|
|
6
7
|
|
|
7
8
|
module TrophyApiClient
|
|
8
|
-
# Points system response for metric events.
|
|
9
|
+
# Points system response for metric events and achievement completions.
|
|
9
10
|
class MetricEventPointsResponse
|
|
11
|
+
# @return [Integer] The user's total points
|
|
12
|
+
attr_reader :total
|
|
13
|
+
# @return [TrophyApiClient::PointsLevel] The user's new level, included only when the level changed as a result of this
|
|
14
|
+
# event.
|
|
15
|
+
attr_reader :level
|
|
16
|
+
# @return [Integer] The points added by this event.
|
|
17
|
+
attr_reader :added
|
|
18
|
+
# @return [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
|
19
|
+
attr_reader :awards
|
|
10
20
|
# @return [String] The ID of the points system
|
|
11
21
|
attr_reader :id
|
|
12
22
|
# @return [String] The key of the points system
|
|
@@ -19,12 +29,6 @@ module TrophyApiClient
|
|
|
19
29
|
attr_reader :badge_url
|
|
20
30
|
# @return [Float] The maximum number of points a user can be awarded in this points system
|
|
21
31
|
attr_reader :max_points
|
|
22
|
-
# @return [Integer] The user's total points
|
|
23
|
-
attr_reader :total
|
|
24
|
-
# @return [Integer] The points added by this event.
|
|
25
|
-
attr_reader :added
|
|
26
|
-
# @return [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
|
27
|
-
attr_reader :awards
|
|
28
32
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
29
33
|
attr_reader :additional_properties
|
|
30
34
|
# @return [Object]
|
|
@@ -33,39 +37,43 @@ module TrophyApiClient
|
|
|
33
37
|
|
|
34
38
|
OMIT = Object.new
|
|
35
39
|
|
|
40
|
+
# @param total [Integer] The user's total points
|
|
41
|
+
# @param level [TrophyApiClient::PointsLevel] The user's new level, included only when the level changed as a result of this
|
|
42
|
+
# event.
|
|
43
|
+
# @param added [Integer] The points added by this event.
|
|
44
|
+
# @param awards [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
|
36
45
|
# @param id [String] The ID of the points system
|
|
37
46
|
# @param key [String] The key of the points system
|
|
38
47
|
# @param name [String] The name of the points system
|
|
39
48
|
# @param description [String] The description of the points system
|
|
40
49
|
# @param badge_url [String] The URL of the badge image for the points system
|
|
41
50
|
# @param max_points [Float] The maximum number of points a user can be awarded in this points system
|
|
42
|
-
# @param total [Integer] The user's total points
|
|
43
|
-
# @param added [Integer] The points added by this event.
|
|
44
|
-
# @param awards [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
|
45
51
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
46
52
|
# @return [TrophyApiClient::MetricEventPointsResponse]
|
|
47
|
-
def initialize(
|
|
48
|
-
additional_properties: nil)
|
|
53
|
+
def initialize(total:, added:, awards:, id:, key:, name:, level: OMIT, description: OMIT, badge_url: OMIT,
|
|
54
|
+
max_points: OMIT, additional_properties: nil)
|
|
55
|
+
@total = total
|
|
56
|
+
@level = level if level != OMIT
|
|
57
|
+
@added = added
|
|
58
|
+
@awards = awards
|
|
49
59
|
@id = id
|
|
50
60
|
@key = key
|
|
51
61
|
@name = name
|
|
52
62
|
@description = description if description != OMIT
|
|
53
63
|
@badge_url = badge_url if badge_url != OMIT
|
|
54
64
|
@max_points = max_points if max_points != OMIT
|
|
55
|
-
@total = total
|
|
56
|
-
@added = added
|
|
57
|
-
@awards = awards
|
|
58
65
|
@additional_properties = additional_properties
|
|
59
66
|
@_field_set = {
|
|
67
|
+
"total": total,
|
|
68
|
+
"level": level,
|
|
69
|
+
"added": added,
|
|
70
|
+
"awards": awards,
|
|
60
71
|
"id": id,
|
|
61
72
|
"key": key,
|
|
62
73
|
"name": name,
|
|
63
74
|
"description": description,
|
|
64
75
|
"badgeUrl": badge_url,
|
|
65
|
-
"maxPoints": max_points
|
|
66
|
-
"total": total,
|
|
67
|
-
"added": added,
|
|
68
|
-
"awards": awards
|
|
76
|
+
"maxPoints": max_points
|
|
69
77
|
}.reject do |_k, v|
|
|
70
78
|
v == OMIT
|
|
71
79
|
end
|
|
@@ -78,28 +86,35 @@ module TrophyApiClient
|
|
|
78
86
|
def self.from_json(json_object:)
|
|
79
87
|
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
80
88
|
parsed_json = JSON.parse(json_object)
|
|
81
|
-
id = parsed_json["id"]
|
|
82
|
-
key = parsed_json["key"]
|
|
83
|
-
name = parsed_json["name"]
|
|
84
|
-
description = parsed_json["description"]
|
|
85
|
-
badge_url = parsed_json["badgeUrl"]
|
|
86
|
-
max_points = parsed_json["maxPoints"]
|
|
87
89
|
total = parsed_json["total"]
|
|
90
|
+
if parsed_json["level"].nil?
|
|
91
|
+
level = nil
|
|
92
|
+
else
|
|
93
|
+
level = parsed_json["level"].to_json
|
|
94
|
+
level = TrophyApiClient::PointsLevel.from_json(json_object: level)
|
|
95
|
+
end
|
|
88
96
|
added = parsed_json["added"]
|
|
89
97
|
awards = parsed_json["awards"]&.map do |item|
|
|
90
98
|
item = item.to_json
|
|
91
99
|
TrophyApiClient::PointsAward.from_json(json_object: item)
|
|
92
100
|
end
|
|
101
|
+
id = parsed_json["id"]
|
|
102
|
+
key = parsed_json["key"]
|
|
103
|
+
name = parsed_json["name"]
|
|
104
|
+
description = parsed_json["description"]
|
|
105
|
+
badge_url = parsed_json["badgeUrl"]
|
|
106
|
+
max_points = parsed_json["maxPoints"]
|
|
93
107
|
new(
|
|
108
|
+
total: total,
|
|
109
|
+
level: level,
|
|
110
|
+
added: added,
|
|
111
|
+
awards: awards,
|
|
94
112
|
id: id,
|
|
95
113
|
key: key,
|
|
96
114
|
name: name,
|
|
97
115
|
description: description,
|
|
98
116
|
badge_url: badge_url,
|
|
99
117
|
max_points: max_points,
|
|
100
|
-
total: total,
|
|
101
|
-
added: added,
|
|
102
|
-
awards: awards,
|
|
103
118
|
additional_properties: struct
|
|
104
119
|
)
|
|
105
120
|
end
|
|
@@ -118,15 +133,16 @@ module TrophyApiClient
|
|
|
118
133
|
# @param obj [Object]
|
|
119
134
|
# @return [Void]
|
|
120
135
|
def self.validate_raw(obj:)
|
|
136
|
+
obj.total.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
|
|
137
|
+
obj.level.nil? || TrophyApiClient::PointsLevel.validate_raw(obj: obj.level)
|
|
138
|
+
obj.added.is_a?(Integer) != false || raise("Passed value for field obj.added is not the expected type, validation failed.")
|
|
139
|
+
obj.awards.is_a?(Array) != false || raise("Passed value for field obj.awards is not the expected type, validation failed.")
|
|
121
140
|
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
|
122
141
|
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
123
142
|
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
124
143
|
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
|
125
144
|
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
|
126
145
|
obj.max_points&.is_a?(Float) != false || raise("Passed value for field obj.max_points is not the expected type, validation failed.")
|
|
127
|
-
obj.total.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
|
|
128
|
-
obj.added.is_a?(Integer) != false || raise("Passed value for field obj.added is not the expected type, validation failed.")
|
|
129
|
-
obj.awards.is_a?(Array) != false || raise("Passed value for field obj.awards is not the expected type, validation failed.")
|
|
130
146
|
end
|
|
131
147
|
end
|
|
132
148
|
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "ostruct"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module TrophyApiClient
|
|
7
|
+
# A level within a points system.
|
|
8
|
+
class PointsLevel
|
|
9
|
+
# @return [String] The ID of the level
|
|
10
|
+
attr_reader :id
|
|
11
|
+
# @return [String] The unique key of the level
|
|
12
|
+
attr_reader :key
|
|
13
|
+
# @return [String] The name of the level
|
|
14
|
+
attr_reader :name
|
|
15
|
+
# @return [String] The description of the level
|
|
16
|
+
attr_reader :description
|
|
17
|
+
# @return [String] The URL of the badge image for the level
|
|
18
|
+
attr_reader :badge_url
|
|
19
|
+
# @return [Integer] The points threshold required to reach this level
|
|
20
|
+
attr_reader :points
|
|
21
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
22
|
+
attr_reader :additional_properties
|
|
23
|
+
# @return [Object]
|
|
24
|
+
attr_reader :_field_set
|
|
25
|
+
protected :_field_set
|
|
26
|
+
|
|
27
|
+
OMIT = Object.new
|
|
28
|
+
|
|
29
|
+
# @param id [String] The ID of the level
|
|
30
|
+
# @param key [String] The unique key of the level
|
|
31
|
+
# @param name [String] The name of the level
|
|
32
|
+
# @param description [String] The description of the level
|
|
33
|
+
# @param badge_url [String] The URL of the badge image for the level
|
|
34
|
+
# @param points [Integer] The points threshold required to reach this level
|
|
35
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
36
|
+
# @return [TrophyApiClient::PointsLevel]
|
|
37
|
+
def initialize(id:, key:, name:, description:, points:, badge_url: OMIT, additional_properties: nil)
|
|
38
|
+
@id = id
|
|
39
|
+
@key = key
|
|
40
|
+
@name = name
|
|
41
|
+
@description = description
|
|
42
|
+
@badge_url = badge_url if badge_url != OMIT
|
|
43
|
+
@points = points
|
|
44
|
+
@additional_properties = additional_properties
|
|
45
|
+
@_field_set = {
|
|
46
|
+
"id": id,
|
|
47
|
+
"key": key,
|
|
48
|
+
"name": name,
|
|
49
|
+
"description": description,
|
|
50
|
+
"badgeUrl": badge_url,
|
|
51
|
+
"points": points
|
|
52
|
+
}.reject do |_k, v|
|
|
53
|
+
v == OMIT
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Deserialize a JSON object to an instance of PointsLevel
|
|
58
|
+
#
|
|
59
|
+
# @param json_object [String]
|
|
60
|
+
# @return [TrophyApiClient::PointsLevel]
|
|
61
|
+
def self.from_json(json_object:)
|
|
62
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
63
|
+
parsed_json = JSON.parse(json_object)
|
|
64
|
+
id = parsed_json["id"]
|
|
65
|
+
key = parsed_json["key"]
|
|
66
|
+
name = parsed_json["name"]
|
|
67
|
+
description = parsed_json["description"]
|
|
68
|
+
badge_url = parsed_json["badgeUrl"]
|
|
69
|
+
points = parsed_json["points"]
|
|
70
|
+
new(
|
|
71
|
+
id: id,
|
|
72
|
+
key: key,
|
|
73
|
+
name: name,
|
|
74
|
+
description: description,
|
|
75
|
+
badge_url: badge_url,
|
|
76
|
+
points: points,
|
|
77
|
+
additional_properties: struct
|
|
78
|
+
)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Serialize an instance of PointsLevel to a JSON object
|
|
82
|
+
#
|
|
83
|
+
# @return [String]
|
|
84
|
+
def to_json(*_args)
|
|
85
|
+
@_field_set&.to_json
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
89
|
+
# hash and check each fields type against the current object's property
|
|
90
|
+
# definitions.
|
|
91
|
+
#
|
|
92
|
+
# @param obj [Object]
|
|
93
|
+
# @return [Void]
|
|
94
|
+
def self.validate_raw(obj:)
|
|
95
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
|
96
|
+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
97
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
98
|
+
obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
|
99
|
+
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
|
100
|
+
obj.points.is_a?(Integer) != false || raise("Passed value for field obj.points is not the expected type, validation failed.")
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "points_level"
|
|
4
|
+
require "ostruct"
|
|
5
|
+
require "json"
|
|
6
|
+
|
|
7
|
+
module TrophyApiClient
|
|
8
|
+
class PointsLevelSummaryResponseItem
|
|
9
|
+
# @return [TrophyApiClient::PointsLevel]
|
|
10
|
+
attr_reader :level
|
|
11
|
+
# @return [Integer] The number of users currently at this level
|
|
12
|
+
attr_reader :users
|
|
13
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
14
|
+
attr_reader :additional_properties
|
|
15
|
+
# @return [Object]
|
|
16
|
+
attr_reader :_field_set
|
|
17
|
+
protected :_field_set
|
|
18
|
+
|
|
19
|
+
OMIT = Object.new
|
|
20
|
+
|
|
21
|
+
# @param level [TrophyApiClient::PointsLevel]
|
|
22
|
+
# @param users [Integer] The number of users currently at this level
|
|
23
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
24
|
+
# @return [TrophyApiClient::PointsLevelSummaryResponseItem]
|
|
25
|
+
def initialize(level:, users:, additional_properties: nil)
|
|
26
|
+
@level = level
|
|
27
|
+
@users = users
|
|
28
|
+
@additional_properties = additional_properties
|
|
29
|
+
@_field_set = { "level": level, "users": users }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Deserialize a JSON object to an instance of PointsLevelSummaryResponseItem
|
|
33
|
+
#
|
|
34
|
+
# @param json_object [String]
|
|
35
|
+
# @return [TrophyApiClient::PointsLevelSummaryResponseItem]
|
|
36
|
+
def self.from_json(json_object:)
|
|
37
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
38
|
+
parsed_json = JSON.parse(json_object)
|
|
39
|
+
if parsed_json["level"].nil?
|
|
40
|
+
level = nil
|
|
41
|
+
else
|
|
42
|
+
level = parsed_json["level"].to_json
|
|
43
|
+
level = TrophyApiClient::PointsLevel.from_json(json_object: level)
|
|
44
|
+
end
|
|
45
|
+
users = parsed_json["users"]
|
|
46
|
+
new(
|
|
47
|
+
level: level,
|
|
48
|
+
users: users,
|
|
49
|
+
additional_properties: struct
|
|
50
|
+
)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Serialize an instance of PointsLevelSummaryResponseItem to a JSON object
|
|
54
|
+
#
|
|
55
|
+
# @return [String]
|
|
56
|
+
def to_json(*_args)
|
|
57
|
+
@_field_set&.to_json
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
61
|
+
# hash and check each fields type against the current object's property
|
|
62
|
+
# definitions.
|
|
63
|
+
#
|
|
64
|
+
# @param obj [Object]
|
|
65
|
+
# @return [Void]
|
|
66
|
+
def self.validate_raw(obj:)
|
|
67
|
+
TrophyApiClient::PointsLevel.validate_raw(obj: obj.level)
|
|
68
|
+
obj.users.is_a?(Integer) != false || raise("Passed value for field obj.users is not the expected type, validation failed.")
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "ostruct"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module TrophyApiClient
|
|
7
|
+
# Base points system fields shared across responses.
|
|
8
|
+
class PointsResponse
|
|
9
|
+
# @return [String] The ID of the points system
|
|
10
|
+
attr_reader :id
|
|
11
|
+
# @return [String] The key of the points system
|
|
12
|
+
attr_reader :key
|
|
13
|
+
# @return [String] The name of the points system
|
|
14
|
+
attr_reader :name
|
|
15
|
+
# @return [String] The description of the points system
|
|
16
|
+
attr_reader :description
|
|
17
|
+
# @return [String] The URL of the badge image for the points system
|
|
18
|
+
attr_reader :badge_url
|
|
19
|
+
# @return [Float] The maximum number of points a user can be awarded in this points system
|
|
20
|
+
attr_reader :max_points
|
|
21
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
22
|
+
attr_reader :additional_properties
|
|
23
|
+
# @return [Object]
|
|
24
|
+
attr_reader :_field_set
|
|
25
|
+
protected :_field_set
|
|
26
|
+
|
|
27
|
+
OMIT = Object.new
|
|
28
|
+
|
|
29
|
+
# @param id [String] The ID of the points system
|
|
30
|
+
# @param key [String] The key of the points system
|
|
31
|
+
# @param name [String] The name of the points system
|
|
32
|
+
# @param description [String] The description of the points system
|
|
33
|
+
# @param badge_url [String] The URL of the badge image for the points system
|
|
34
|
+
# @param max_points [Float] The maximum number of points a user can be awarded in this points system
|
|
35
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
36
|
+
# @return [TrophyApiClient::PointsResponse]
|
|
37
|
+
def initialize(id:, key:, name:, description: OMIT, badge_url: OMIT, max_points: OMIT, additional_properties: nil)
|
|
38
|
+
@id = id
|
|
39
|
+
@key = key
|
|
40
|
+
@name = name
|
|
41
|
+
@description = description if description != OMIT
|
|
42
|
+
@badge_url = badge_url if badge_url != OMIT
|
|
43
|
+
@max_points = max_points if max_points != OMIT
|
|
44
|
+
@additional_properties = additional_properties
|
|
45
|
+
@_field_set = {
|
|
46
|
+
"id": id,
|
|
47
|
+
"key": key,
|
|
48
|
+
"name": name,
|
|
49
|
+
"description": description,
|
|
50
|
+
"badgeUrl": badge_url,
|
|
51
|
+
"maxPoints": max_points
|
|
52
|
+
}.reject do |_k, v|
|
|
53
|
+
v == OMIT
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Deserialize a JSON object to an instance of PointsResponse
|
|
58
|
+
#
|
|
59
|
+
# @param json_object [String]
|
|
60
|
+
# @return [TrophyApiClient::PointsResponse]
|
|
61
|
+
def self.from_json(json_object:)
|
|
62
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
63
|
+
parsed_json = JSON.parse(json_object)
|
|
64
|
+
id = parsed_json["id"]
|
|
65
|
+
key = parsed_json["key"]
|
|
66
|
+
name = parsed_json["name"]
|
|
67
|
+
description = parsed_json["description"]
|
|
68
|
+
badge_url = parsed_json["badgeUrl"]
|
|
69
|
+
max_points = parsed_json["maxPoints"]
|
|
70
|
+
new(
|
|
71
|
+
id: id,
|
|
72
|
+
key: key,
|
|
73
|
+
name: name,
|
|
74
|
+
description: description,
|
|
75
|
+
badge_url: badge_url,
|
|
76
|
+
max_points: max_points,
|
|
77
|
+
additional_properties: struct
|
|
78
|
+
)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Serialize an instance of PointsResponse to a JSON object
|
|
82
|
+
#
|
|
83
|
+
# @return [String]
|
|
84
|
+
def to_json(*_args)
|
|
85
|
+
@_field_set&.to_json
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
89
|
+
# hash and check each fields type against the current object's property
|
|
90
|
+
# definitions.
|
|
91
|
+
#
|
|
92
|
+
# @param obj [Object]
|
|
93
|
+
# @return [Void]
|
|
94
|
+
def self.validate_raw(obj:)
|
|
95
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
|
96
|
+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
97
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
98
|
+
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
|
99
|
+
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
|
100
|
+
obj.max_points&.is_a?(Float) != false || raise("Passed value for field obj.max_points is not the expected type, validation failed.")
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "user"
|
|
4
|
+
require_relative "webhooks_points_level_changed_payload_points"
|
|
5
|
+
require_relative "points_level"
|
|
6
|
+
require "ostruct"
|
|
7
|
+
require "json"
|
|
8
|
+
|
|
9
|
+
module TrophyApiClient
|
|
10
|
+
class WebhooksPointsLevelChangedPayload
|
|
11
|
+
# @return [String] The webhook event type.
|
|
12
|
+
attr_reader :type
|
|
13
|
+
# @return [TrophyApiClient::User] The user whose level changed.
|
|
14
|
+
attr_reader :user
|
|
15
|
+
# @return [TrophyApiClient::WebhooksPointsLevelChangedPayloadPoints] The points system in which the level changed.
|
|
16
|
+
attr_reader :points
|
|
17
|
+
# @return [TrophyApiClient::PointsLevel] The user's previous level, or null if the user had no level.
|
|
18
|
+
attr_reader :previous_level
|
|
19
|
+
# @return [TrophyApiClient::PointsLevel] The user's new level, or null if the user no longer has a level.
|
|
20
|
+
attr_reader :new_level
|
|
21
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
22
|
+
attr_reader :additional_properties
|
|
23
|
+
# @return [Object]
|
|
24
|
+
attr_reader :_field_set
|
|
25
|
+
protected :_field_set
|
|
26
|
+
|
|
27
|
+
OMIT = Object.new
|
|
28
|
+
|
|
29
|
+
# @param type [String] The webhook event type.
|
|
30
|
+
# @param user [TrophyApiClient::User] The user whose level changed.
|
|
31
|
+
# @param points [TrophyApiClient::WebhooksPointsLevelChangedPayloadPoints] The points system in which the level changed.
|
|
32
|
+
# @param previous_level [TrophyApiClient::PointsLevel] The user's previous level, or null if the user had no level.
|
|
33
|
+
# @param new_level [TrophyApiClient::PointsLevel] The user's new level, or null if the user no longer has a level.
|
|
34
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
35
|
+
# @return [TrophyApiClient::WebhooksPointsLevelChangedPayload]
|
|
36
|
+
def initialize(type:, user:, points:, previous_level: OMIT, new_level: OMIT, additional_properties: nil)
|
|
37
|
+
@type = type
|
|
38
|
+
@user = user
|
|
39
|
+
@points = points
|
|
40
|
+
@previous_level = previous_level if previous_level != OMIT
|
|
41
|
+
@new_level = new_level if new_level != OMIT
|
|
42
|
+
@additional_properties = additional_properties
|
|
43
|
+
@_field_set = {
|
|
44
|
+
"type": type,
|
|
45
|
+
"user": user,
|
|
46
|
+
"points": points,
|
|
47
|
+
"previousLevel": previous_level,
|
|
48
|
+
"newLevel": new_level
|
|
49
|
+
}.reject do |_k, v|
|
|
50
|
+
v == OMIT
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Deserialize a JSON object to an instance of WebhooksPointsLevelChangedPayload
|
|
55
|
+
#
|
|
56
|
+
# @param json_object [String]
|
|
57
|
+
# @return [TrophyApiClient::WebhooksPointsLevelChangedPayload]
|
|
58
|
+
def self.from_json(json_object:)
|
|
59
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
60
|
+
parsed_json = JSON.parse(json_object)
|
|
61
|
+
type = parsed_json["type"]
|
|
62
|
+
if parsed_json["user"].nil?
|
|
63
|
+
user = nil
|
|
64
|
+
else
|
|
65
|
+
user = parsed_json["user"].to_json
|
|
66
|
+
user = TrophyApiClient::User.from_json(json_object: user)
|
|
67
|
+
end
|
|
68
|
+
if parsed_json["points"].nil?
|
|
69
|
+
points = nil
|
|
70
|
+
else
|
|
71
|
+
points = parsed_json["points"].to_json
|
|
72
|
+
points = TrophyApiClient::WebhooksPointsLevelChangedPayloadPoints.from_json(json_object: points)
|
|
73
|
+
end
|
|
74
|
+
if parsed_json["previousLevel"].nil?
|
|
75
|
+
previous_level = nil
|
|
76
|
+
else
|
|
77
|
+
previous_level = parsed_json["previousLevel"].to_json
|
|
78
|
+
previous_level = TrophyApiClient::PointsLevel.from_json(json_object: previous_level)
|
|
79
|
+
end
|
|
80
|
+
if parsed_json["newLevel"].nil?
|
|
81
|
+
new_level = nil
|
|
82
|
+
else
|
|
83
|
+
new_level = parsed_json["newLevel"].to_json
|
|
84
|
+
new_level = TrophyApiClient::PointsLevel.from_json(json_object: new_level)
|
|
85
|
+
end
|
|
86
|
+
new(
|
|
87
|
+
type: type,
|
|
88
|
+
user: user,
|
|
89
|
+
points: points,
|
|
90
|
+
previous_level: previous_level,
|
|
91
|
+
new_level: new_level,
|
|
92
|
+
additional_properties: struct
|
|
93
|
+
)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Serialize an instance of WebhooksPointsLevelChangedPayload to a JSON object
|
|
97
|
+
#
|
|
98
|
+
# @return [String]
|
|
99
|
+
def to_json(*_args)
|
|
100
|
+
@_field_set&.to_json
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
104
|
+
# hash and check each fields type against the current object's property
|
|
105
|
+
# definitions.
|
|
106
|
+
#
|
|
107
|
+
# @param obj [Object]
|
|
108
|
+
# @return [Void]
|
|
109
|
+
def self.validate_raw(obj:)
|
|
110
|
+
obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
|
|
111
|
+
TrophyApiClient::User.validate_raw(obj: obj.user)
|
|
112
|
+
TrophyApiClient::WebhooksPointsLevelChangedPayloadPoints.validate_raw(obj: obj.points)
|
|
113
|
+
obj.previous_level.nil? || TrophyApiClient::PointsLevel.validate_raw(obj: obj.previous_level)
|
|
114
|
+
obj.new_level.nil? || TrophyApiClient::PointsLevel.validate_raw(obj: obj.new_level)
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "ostruct"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module TrophyApiClient
|
|
7
|
+
# The points system in which the level changed.
|
|
8
|
+
class WebhooksPointsLevelChangedPayloadPoints
|
|
9
|
+
# @return [Integer] The user's total points in this system.
|
|
10
|
+
attr_reader :total
|
|
11
|
+
# @return [String] The ID of the points system
|
|
12
|
+
attr_reader :id
|
|
13
|
+
# @return [String] The key of the points system
|
|
14
|
+
attr_reader :key
|
|
15
|
+
# @return [String] The name of the points system
|
|
16
|
+
attr_reader :name
|
|
17
|
+
# @return [String] The description of the points system
|
|
18
|
+
attr_reader :description
|
|
19
|
+
# @return [String] The URL of the badge image for the points system
|
|
20
|
+
attr_reader :badge_url
|
|
21
|
+
# @return [Float] The maximum number of points a user can be awarded in this points system
|
|
22
|
+
attr_reader :max_points
|
|
23
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
24
|
+
attr_reader :additional_properties
|
|
25
|
+
# @return [Object]
|
|
26
|
+
attr_reader :_field_set
|
|
27
|
+
protected :_field_set
|
|
28
|
+
|
|
29
|
+
OMIT = Object.new
|
|
30
|
+
|
|
31
|
+
# @param total [Integer] The user's total points in this system.
|
|
32
|
+
# @param id [String] The ID of the points system
|
|
33
|
+
# @param key [String] The key of the points system
|
|
34
|
+
# @param name [String] The name of the points system
|
|
35
|
+
# @param description [String] The description of the points system
|
|
36
|
+
# @param badge_url [String] The URL of the badge image for the points system
|
|
37
|
+
# @param max_points [Float] The maximum number of points a user can be awarded in this points system
|
|
38
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
39
|
+
# @return [TrophyApiClient::WebhooksPointsLevelChangedPayloadPoints]
|
|
40
|
+
def initialize(total:, id:, key:, name:, description: OMIT, badge_url: OMIT, max_points: OMIT,
|
|
41
|
+
additional_properties: nil)
|
|
42
|
+
@total = total
|
|
43
|
+
@id = id
|
|
44
|
+
@key = key
|
|
45
|
+
@name = name
|
|
46
|
+
@description = description if description != OMIT
|
|
47
|
+
@badge_url = badge_url if badge_url != OMIT
|
|
48
|
+
@max_points = max_points if max_points != OMIT
|
|
49
|
+
@additional_properties = additional_properties
|
|
50
|
+
@_field_set = {
|
|
51
|
+
"total": total,
|
|
52
|
+
"id": id,
|
|
53
|
+
"key": key,
|
|
54
|
+
"name": name,
|
|
55
|
+
"description": description,
|
|
56
|
+
"badgeUrl": badge_url,
|
|
57
|
+
"maxPoints": max_points
|
|
58
|
+
}.reject do |_k, v|
|
|
59
|
+
v == OMIT
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Deserialize a JSON object to an instance of
|
|
64
|
+
# WebhooksPointsLevelChangedPayloadPoints
|
|
65
|
+
#
|
|
66
|
+
# @param json_object [String]
|
|
67
|
+
# @return [TrophyApiClient::WebhooksPointsLevelChangedPayloadPoints]
|
|
68
|
+
def self.from_json(json_object:)
|
|
69
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
70
|
+
parsed_json = JSON.parse(json_object)
|
|
71
|
+
total = parsed_json["total"]
|
|
72
|
+
id = parsed_json["id"]
|
|
73
|
+
key = parsed_json["key"]
|
|
74
|
+
name = parsed_json["name"]
|
|
75
|
+
description = parsed_json["description"]
|
|
76
|
+
badge_url = parsed_json["badgeUrl"]
|
|
77
|
+
max_points = parsed_json["maxPoints"]
|
|
78
|
+
new(
|
|
79
|
+
total: total,
|
|
80
|
+
id: id,
|
|
81
|
+
key: key,
|
|
82
|
+
name: name,
|
|
83
|
+
description: description,
|
|
84
|
+
badge_url: badge_url,
|
|
85
|
+
max_points: max_points,
|
|
86
|
+
additional_properties: struct
|
|
87
|
+
)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Serialize an instance of WebhooksPointsLevelChangedPayloadPoints to a JSON
|
|
91
|
+
# object
|
|
92
|
+
#
|
|
93
|
+
# @return [String]
|
|
94
|
+
def to_json(*_args)
|
|
95
|
+
@_field_set&.to_json
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
99
|
+
# hash and check each fields type against the current object's property
|
|
100
|
+
# definitions.
|
|
101
|
+
#
|
|
102
|
+
# @param obj [Object]
|
|
103
|
+
# @return [Void]
|
|
104
|
+
def self.validate_raw(obj:)
|
|
105
|
+
obj.total.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
|
|
106
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
|
107
|
+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
108
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
109
|
+
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
|
110
|
+
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
|
111
|
+
obj.max_points&.is_a?(Float) != false || raise("Passed value for field obj.max_points is not the expected type, validation failed.")
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
data/lib/types_export.rb
CHANGED
|
@@ -18,6 +18,8 @@ require_relative "trophy_api_client/types/webhooks_streak_lost_payload"
|
|
|
18
18
|
require_relative "trophy_api_client/types/webhooks_streak_freeze_consumed_payload"
|
|
19
19
|
require_relative "trophy_api_client/types/webhooks_streak_freeze_earned_payload"
|
|
20
20
|
require_relative "trophy_api_client/types/webhooks_points_changed_payload"
|
|
21
|
+
require_relative "trophy_api_client/types/webhooks_points_level_changed_payload_points"
|
|
22
|
+
require_relative "trophy_api_client/types/webhooks_points_level_changed_payload"
|
|
21
23
|
require_relative "trophy_api_client/types/webhooks_points_boost_started_payload"
|
|
22
24
|
require_relative "trophy_api_client/types/webhooks_points_boost_finished_payload"
|
|
23
25
|
require_relative "trophy_api_client/types/webhooks_leaderboard_started_payload"
|
|
@@ -42,7 +44,11 @@ require_relative "trophy_api_client/types/points_boost"
|
|
|
42
44
|
require_relative "trophy_api_client/types/points_boost_webhook_payload_status"
|
|
43
45
|
require_relative "trophy_api_client/types/points_boost_webhook_payload_rounding"
|
|
44
46
|
require_relative "trophy_api_client/types/points_boost_webhook_payload"
|
|
47
|
+
require_relative "trophy_api_client/types/points_response"
|
|
45
48
|
require_relative "trophy_api_client/types/get_user_points_response"
|
|
49
|
+
require_relative "trophy_api_client/types/points_level_summary_response_item"
|
|
50
|
+
require_relative "trophy_api_client/types/points_level_summary_response"
|
|
51
|
+
require_relative "trophy_api_client/types/points_level"
|
|
46
52
|
require_relative "trophy_api_client/types/leaderboard_response_rank_by"
|
|
47
53
|
require_relative "trophy_api_client/types/leaderboard_response_run_unit"
|
|
48
54
|
require_relative "trophy_api_client/types/leaderboard_response"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: trophy_api_client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1
|
|
4
|
+
version: 1.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Trophy Labs, Inc
|
|
@@ -158,7 +158,11 @@ files:
|
|
|
158
158
|
- lib/trophy_api_client/types/points_boost_webhook_payload.rb
|
|
159
159
|
- lib/trophy_api_client/types/points_boost_webhook_payload_rounding.rb
|
|
160
160
|
- lib/trophy_api_client/types/points_boost_webhook_payload_status.rb
|
|
161
|
+
- lib/trophy_api_client/types/points_level.rb
|
|
162
|
+
- lib/trophy_api_client/types/points_level_summary_response.rb
|
|
163
|
+
- lib/trophy_api_client/types/points_level_summary_response_item.rb
|
|
161
164
|
- lib/trophy_api_client/types/points_range.rb
|
|
165
|
+
- lib/trophy_api_client/types/points_response.rb
|
|
162
166
|
- lib/trophy_api_client/types/points_summary_response.rb
|
|
163
167
|
- lib/trophy_api_client/types/points_system_response.rb
|
|
164
168
|
- lib/trophy_api_client/types/points_trigger.rb
|
|
@@ -192,6 +196,8 @@ files:
|
|
|
192
196
|
- lib/trophy_api_client/types/webhooks_points_boost_finished_payload.rb
|
|
193
197
|
- lib/trophy_api_client/types/webhooks_points_boost_started_payload.rb
|
|
194
198
|
- lib/trophy_api_client/types/webhooks_points_changed_payload.rb
|
|
199
|
+
- lib/trophy_api_client/types/webhooks_points_level_changed_payload.rb
|
|
200
|
+
- lib/trophy_api_client/types/webhooks_points_level_changed_payload_points.rb
|
|
195
201
|
- lib/trophy_api_client/types/webhooks_streak_extended_payload.rb
|
|
196
202
|
- lib/trophy_api_client/types/webhooks_streak_freeze_consumed_payload.rb
|
|
197
203
|
- lib/trophy_api_client/types/webhooks_streak_freeze_earned_payload.rb
|
|
@@ -235,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
235
241
|
- !ruby/object:Gem::Version
|
|
236
242
|
version: '0'
|
|
237
243
|
requirements: []
|
|
238
|
-
rubygems_version: 4.0.
|
|
244
|
+
rubygems_version: 4.0.6
|
|
239
245
|
specification_version: 4
|
|
240
246
|
summary: Ruby library for the Trophy API.
|
|
241
247
|
test_files: []
|