trophy_api_client 1.1.1 → 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/achievement_response.rb +11 -1
- data/lib/trophy_api_client/types/achievement_response_trigger.rb +1 -0
- data/lib/trophy_api_client/types/achievement_with_stats_response.rb +11 -1
- 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/user_achievement_response.rb +11 -1
- data/lib/trophy_api_client/types/user_achievement_with_stats_response.rb +11 -1
- 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
|
@@ -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
|
|
@@ -28,6 +28,9 @@ module TrophyApiClient
|
|
|
28
28
|
# @return [Integer] The length of the streak required to complete the achievement (only applicable
|
|
29
29
|
# if trigger = 'streak')
|
|
30
30
|
attr_reader :streak_length
|
|
31
|
+
# @return [Array<String>] The IDs of the prerequisite achievements that must be completed to earn this
|
|
32
|
+
# achievement (only applicable if trigger = 'achievement')
|
|
33
|
+
attr_reader :achievement_ids
|
|
31
34
|
# @return [String] The ID of the metric associated with this achievement (only applicable if
|
|
32
35
|
# trigger = 'metric')
|
|
33
36
|
attr_reader :metric_id
|
|
@@ -62,6 +65,8 @@ module TrophyApiClient
|
|
|
62
65
|
# trigger = 'api')
|
|
63
66
|
# @param streak_length [Integer] The length of the streak required to complete the achievement (only applicable
|
|
64
67
|
# if trigger = 'streak')
|
|
68
|
+
# @param achievement_ids [Array<String>] The IDs of the prerequisite achievements that must be completed to earn this
|
|
69
|
+
# achievement (only applicable if trigger = 'achievement')
|
|
65
70
|
# @param metric_id [String] The ID of the metric associated with this achievement (only applicable if
|
|
66
71
|
# trigger = 'metric')
|
|
67
72
|
# @param metric_value [Float] The value of the metric required to complete the achievement (only applicable if
|
|
@@ -75,7 +80,7 @@ module TrophyApiClient
|
|
|
75
80
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
76
81
|
# @return [TrophyApiClient::UserAchievementResponse]
|
|
77
82
|
def initialize(id:, name:, trigger:, achieved_at: OMIT, description: OMIT, badge_url: OMIT, key: OMIT,
|
|
78
|
-
streak_length: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, user_attributes: OMIT, event_attribute: OMIT, additional_properties: nil)
|
|
83
|
+
streak_length: OMIT, achievement_ids: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, user_attributes: OMIT, event_attribute: OMIT, additional_properties: nil)
|
|
79
84
|
@achieved_at = achieved_at if achieved_at != OMIT
|
|
80
85
|
@id = id
|
|
81
86
|
@name = name
|
|
@@ -84,6 +89,7 @@ module TrophyApiClient
|
|
|
84
89
|
@badge_url = badge_url if badge_url != OMIT
|
|
85
90
|
@key = key if key != OMIT
|
|
86
91
|
@streak_length = streak_length if streak_length != OMIT
|
|
92
|
+
@achievement_ids = achievement_ids if achievement_ids != OMIT
|
|
87
93
|
@metric_id = metric_id if metric_id != OMIT
|
|
88
94
|
@metric_value = metric_value if metric_value != OMIT
|
|
89
95
|
@metric_name = metric_name if metric_name != OMIT
|
|
@@ -99,6 +105,7 @@ module TrophyApiClient
|
|
|
99
105
|
"badgeUrl": badge_url,
|
|
100
106
|
"key": key,
|
|
101
107
|
"streakLength": streak_length,
|
|
108
|
+
"achievementIds": achievement_ids,
|
|
102
109
|
"metricId": metric_id,
|
|
103
110
|
"metricValue": metric_value,
|
|
104
111
|
"metricName": metric_name,
|
|
@@ -124,6 +131,7 @@ module TrophyApiClient
|
|
|
124
131
|
badge_url = parsed_json["badgeUrl"]
|
|
125
132
|
key = parsed_json["key"]
|
|
126
133
|
streak_length = parsed_json["streakLength"]
|
|
134
|
+
achievement_ids = parsed_json["achievementIds"]
|
|
127
135
|
metric_id = parsed_json["metricId"]
|
|
128
136
|
metric_value = parsed_json["metricValue"]
|
|
129
137
|
metric_name = parsed_json["metricName"]
|
|
@@ -146,6 +154,7 @@ module TrophyApiClient
|
|
|
146
154
|
badge_url: badge_url,
|
|
147
155
|
key: key,
|
|
148
156
|
streak_length: streak_length,
|
|
157
|
+
achievement_ids: achievement_ids,
|
|
149
158
|
metric_id: metric_id,
|
|
150
159
|
metric_value: metric_value,
|
|
151
160
|
metric_name: metric_name,
|
|
@@ -177,6 +186,7 @@ module TrophyApiClient
|
|
|
177
186
|
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
|
178
187
|
obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
179
188
|
obj.streak_length&.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.")
|
|
189
|
+
obj.achievement_ids&.is_a?(Array) != false || raise("Passed value for field obj.achievement_ids is not the expected type, validation failed.")
|
|
180
190
|
obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
|
|
181
191
|
obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
|
|
182
192
|
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
|
@@ -32,6 +32,9 @@ module TrophyApiClient
|
|
|
32
32
|
# @return [Integer] The length of the streak required to complete the achievement (only applicable
|
|
33
33
|
# if trigger = 'streak')
|
|
34
34
|
attr_reader :streak_length
|
|
35
|
+
# @return [Array<String>] The IDs of the prerequisite achievements that must be completed to earn this
|
|
36
|
+
# achievement (only applicable if trigger = 'achievement')
|
|
37
|
+
attr_reader :achievement_ids
|
|
35
38
|
# @return [String] The ID of the metric associated with this achievement (only applicable if
|
|
36
39
|
# trigger = 'metric')
|
|
37
40
|
attr_reader :metric_id
|
|
@@ -68,6 +71,8 @@ module TrophyApiClient
|
|
|
68
71
|
# trigger = 'api')
|
|
69
72
|
# @param streak_length [Integer] The length of the streak required to complete the achievement (only applicable
|
|
70
73
|
# if trigger = 'streak')
|
|
74
|
+
# @param achievement_ids [Array<String>] The IDs of the prerequisite achievements that must be completed to earn this
|
|
75
|
+
# achievement (only applicable if trigger = 'achievement')
|
|
71
76
|
# @param metric_id [String] The ID of the metric associated with this achievement (only applicable if
|
|
72
77
|
# trigger = 'metric')
|
|
73
78
|
# @param metric_value [Float] The value of the metric required to complete the achievement (only applicable if
|
|
@@ -81,7 +86,7 @@ module TrophyApiClient
|
|
|
81
86
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
82
87
|
# @return [TrophyApiClient::UserAchievementWithStatsResponse]
|
|
83
88
|
def initialize(completions:, rarity:, id:, name:, trigger:, achieved_at: OMIT, description: OMIT, badge_url: OMIT,
|
|
84
|
-
key: OMIT, streak_length: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, user_attributes: OMIT, event_attribute: OMIT, additional_properties: nil)
|
|
89
|
+
key: OMIT, streak_length: OMIT, achievement_ids: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, user_attributes: OMIT, event_attribute: OMIT, additional_properties: nil)
|
|
85
90
|
@achieved_at = achieved_at if achieved_at != OMIT
|
|
86
91
|
@completions = completions
|
|
87
92
|
@rarity = rarity
|
|
@@ -92,6 +97,7 @@ module TrophyApiClient
|
|
|
92
97
|
@badge_url = badge_url if badge_url != OMIT
|
|
93
98
|
@key = key if key != OMIT
|
|
94
99
|
@streak_length = streak_length if streak_length != OMIT
|
|
100
|
+
@achievement_ids = achievement_ids if achievement_ids != OMIT
|
|
95
101
|
@metric_id = metric_id if metric_id != OMIT
|
|
96
102
|
@metric_value = metric_value if metric_value != OMIT
|
|
97
103
|
@metric_name = metric_name if metric_name != OMIT
|
|
@@ -109,6 +115,7 @@ module TrophyApiClient
|
|
|
109
115
|
"badgeUrl": badge_url,
|
|
110
116
|
"key": key,
|
|
111
117
|
"streakLength": streak_length,
|
|
118
|
+
"achievementIds": achievement_ids,
|
|
112
119
|
"metricId": metric_id,
|
|
113
120
|
"metricValue": metric_value,
|
|
114
121
|
"metricName": metric_name,
|
|
@@ -136,6 +143,7 @@ module TrophyApiClient
|
|
|
136
143
|
badge_url = parsed_json["badgeUrl"]
|
|
137
144
|
key = parsed_json["key"]
|
|
138
145
|
streak_length = parsed_json["streakLength"]
|
|
146
|
+
achievement_ids = parsed_json["achievementIds"]
|
|
139
147
|
metric_id = parsed_json["metricId"]
|
|
140
148
|
metric_value = parsed_json["metricValue"]
|
|
141
149
|
metric_name = parsed_json["metricName"]
|
|
@@ -160,6 +168,7 @@ module TrophyApiClient
|
|
|
160
168
|
badge_url: badge_url,
|
|
161
169
|
key: key,
|
|
162
170
|
streak_length: streak_length,
|
|
171
|
+
achievement_ids: achievement_ids,
|
|
163
172
|
metric_id: metric_id,
|
|
164
173
|
metric_value: metric_value,
|
|
165
174
|
metric_name: metric_name,
|
|
@@ -193,6 +202,7 @@ module TrophyApiClient
|
|
|
193
202
|
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
|
194
203
|
obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
195
204
|
obj.streak_length&.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.")
|
|
205
|
+
obj.achievement_ids&.is_a?(Array) != false || raise("Passed value for field obj.achievement_ids is not the expected type, validation failed.")
|
|
196
206
|
obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
|
|
197
207
|
obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
|
|
198
208
|
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
|
@@ -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"
|