trophy_api_client 1.0.29 → 1.0.30

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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gemconfig.rb +1 -1
  3. data/lib/trophy_api_client/achievements/client.rb +2 -2
  4. data/lib/trophy_api_client/leaderboards/client.rb +9 -5
  5. data/lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item.rb +186 -0
  6. data/lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item_status.rb +12 -0
  7. data/lib/trophy_api_client/metrics/client.rb +2 -2
  8. data/lib/trophy_api_client/streaks/client.rb +2 -2
  9. data/lib/trophy_api_client/types/achievement_completion_response.rb +9 -11
  10. data/lib/trophy_api_client/types/achievement_completion_response_achievement.rb +171 -0
  11. data/lib/trophy_api_client/types/achievement_response.rb +5 -19
  12. data/lib/trophy_api_client/types/achievement_with_stats_response.rb +9 -23
  13. data/lib/trophy_api_client/types/bulk_streak_response_item.rb +4 -6
  14. data/lib/trophy_api_client/types/completed_achievement_response.rb +7 -21
  15. data/lib/trophy_api_client/types/event_response.rb +10 -10
  16. data/lib/trophy_api_client/types/get_user_points_response.rb +21 -4
  17. data/lib/trophy_api_client/types/leaderboard_response.rb +8 -16
  18. data/lib/trophy_api_client/types/leaderboard_response_run_unit.rb +11 -0
  19. data/lib/trophy_api_client/types/leaderboard_response_with_rankings.rb +17 -16
  20. data/lib/trophy_api_client/types/{leaderboard_response_status.rb → leaderboard_response_with_rankings_status.rb} +1 -1
  21. data/lib/trophy_api_client/types/metric_event_leaderboard_response.rb +11 -19
  22. data/lib/trophy_api_client/types/metric_event_points_response.rb +24 -8
  23. data/lib/trophy_api_client/types/metric_event_streak_response.rb +4 -4
  24. data/lib/trophy_api_client/types/points_award.rb +6 -6
  25. data/lib/trophy_api_client/types/points_range.rb +14 -16
  26. data/lib/trophy_api_client/types/points_system_response.rb +10 -1
  27. data/lib/trophy_api_client/types/points_trigger.rb +30 -11
  28. data/lib/trophy_api_client/types/points_trigger_response.rb +39 -22
  29. data/lib/trophy_api_client/types/points_trigger_response_time_unit.rb +9 -0
  30. data/lib/trophy_api_client/types/points_trigger_response_type.rb +2 -0
  31. data/lib/trophy_api_client/types/points_trigger_time_unit.rb +9 -0
  32. data/lib/trophy_api_client/types/points_trigger_type.rb +2 -0
  33. data/lib/trophy_api_client/types/updated_user.rb +11 -11
  34. data/lib/trophy_api_client/types/upserted_user.rb +12 -12
  35. data/lib/trophy_api_client/types/user.rb +18 -18
  36. data/lib/trophy_api_client/types/user_leaderboard_response.rb +8 -28
  37. data/lib/trophy_api_client/types/user_leaderboard_response_with_history.rb +208 -0
  38. data/lib/trophy_api_client/types/webhook_user_leaderboard_response.rb +212 -0
  39. data/lib/trophy_api_client/types/webhooks_achievement_completed_payload.rb +84 -0
  40. data/lib/trophy_api_client/types/webhooks_leaderboard_changed_payload.rb +71 -0
  41. data/lib/trophy_api_client/types/webhooks_leaderboard_finished_payload.rb +71 -0
  42. data/lib/trophy_api_client/types/webhooks_leaderboard_rank_changed_payload.rb +85 -0
  43. data/lib/trophy_api_client/types/webhooks_leaderboard_started_payload.rb +71 -0
  44. data/lib/trophy_api_client/types/webhooks_points_changed_payload.rb +84 -0
  45. data/lib/trophy_api_client/types/webhooks_streak_extended_payload.rb +84 -0
  46. data/lib/trophy_api_client/types/webhooks_streak_freeze_consumed_payload.rb +85 -0
  47. data/lib/trophy_api_client/types/webhooks_streak_freeze_earned_payload.rb +85 -0
  48. data/lib/trophy_api_client/types/webhooks_streak_lost_payload.rb +78 -0
  49. data/lib/trophy_api_client/types/webhooks_streak_started_payload.rb +84 -0
  50. data/lib/trophy_api_client/users/client.rb +25 -17
  51. data/lib/trophy_api_client/version.rb +1 -1
  52. data/lib/types_export.rb +20 -1
  53. metadata +21 -2
@@ -0,0 +1,208 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "leaderboard_event"
4
+ require_relative "leaderboard_response_rank_by"
5
+ require_relative "leaderboard_response_run_unit"
6
+ require "ostruct"
7
+ require "json"
8
+
9
+ module TrophyApiClient
10
+ # A user's data for a specific leaderboard including rank, value, and history.
11
+ class UserLeaderboardResponseWithHistory
12
+ # @return [Array<TrophyApiClient::LeaderboardEvent>] An array of events showing the user's rank and value changes over time.
13
+ attr_reader :history
14
+ # @return [Integer] The user's current rank in this leaderboard. Null if the user is not on the
15
+ # leaderboard.
16
+ attr_reader :rank
17
+ # @return [Integer] The user's current value in this leaderboard. Null if the user is not on the
18
+ # leaderboard.
19
+ attr_reader :value
20
+ # @return [String] The unique ID of the leaderboard.
21
+ attr_reader :id
22
+ # @return [String] The user-facing name of the leaderboard.
23
+ attr_reader :name
24
+ # @return [String] The unique key used to reference the leaderboard in APIs.
25
+ attr_reader :key
26
+ # @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
27
+ attr_reader :rank_by
28
+ # @return [String] The key of the metric to rank by, if rankBy is 'metric'.
29
+ attr_reader :metric_key
30
+ # @return [String] The name of the metric to rank by, if rankBy is 'metric'.
31
+ attr_reader :metric_name
32
+ # @return [String] The key of the points system to rank by, if rankBy is 'points'.
33
+ attr_reader :points_system_key
34
+ # @return [String] The name of the points system to rank by, if rankBy is 'points'.
35
+ attr_reader :points_system_name
36
+ # @return [String] The user-facing description of the leaderboard.
37
+ attr_reader :description
38
+ # @return [String] The start date of the leaderboard in YYYY-MM-DD format.
39
+ attr_reader :start
40
+ # @return [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
41
+ # forever.
42
+ attr_reader :end_
43
+ # @return [Integer] The maximum number of participants in the leaderboard.
44
+ attr_reader :max_participants
45
+ # @return [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time
46
+ # leaderboards.
47
+ attr_reader :run_unit
48
+ # @return [Integer] The interval between repetitions, relative to the start date and repetition
49
+ # type.
50
+ attr_reader :run_interval
51
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
52
+ attr_reader :additional_properties
53
+ # @return [Object]
54
+ attr_reader :_field_set
55
+ protected :_field_set
56
+
57
+ OMIT = Object.new
58
+
59
+ # @param history [Array<TrophyApiClient::LeaderboardEvent>] An array of events showing the user's rank and value changes over time.
60
+ # @param rank [Integer] The user's current rank in this leaderboard. Null if the user is not on the
61
+ # leaderboard.
62
+ # @param value [Integer] The user's current value in this leaderboard. Null if the user is not on the
63
+ # leaderboard.
64
+ # @param id [String] The unique ID of the leaderboard.
65
+ # @param name [String] The user-facing name of the leaderboard.
66
+ # @param key [String] The unique key used to reference the leaderboard in APIs.
67
+ # @param rank_by [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
68
+ # @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
69
+ # @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
70
+ # @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
71
+ # @param points_system_name [String] The name of the points system to rank by, if rankBy is 'points'.
72
+ # @param description [String] The user-facing description of the leaderboard.
73
+ # @param start [String] The start date of the leaderboard in YYYY-MM-DD format.
74
+ # @param end_ [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
75
+ # forever.
76
+ # @param max_participants [Integer] The maximum number of participants in the leaderboard.
77
+ # @param run_unit [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time
78
+ # leaderboards.
79
+ # @param run_interval [Integer] The interval between repetitions, relative to the start date and repetition
80
+ # type.
81
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
82
+ # @return [TrophyApiClient::UserLeaderboardResponseWithHistory]
83
+ def initialize(history:, id:, name:, key:, rank_by:, description:, start:, max_participants:, run_interval:, rank: OMIT, value: OMIT, metric_key: OMIT, metric_name: OMIT,
84
+ points_system_key: OMIT, points_system_name: OMIT, end_: OMIT, run_unit: OMIT, additional_properties: nil)
85
+ @history = history
86
+ @rank = rank if rank != OMIT
87
+ @value = value if value != OMIT
88
+ @id = id
89
+ @name = name
90
+ @key = key
91
+ @rank_by = rank_by
92
+ @metric_key = metric_key if metric_key != OMIT
93
+ @metric_name = metric_name if metric_name != OMIT
94
+ @points_system_key = points_system_key if points_system_key != OMIT
95
+ @points_system_name = points_system_name if points_system_name != OMIT
96
+ @description = description
97
+ @start = start
98
+ @end_ = end_ if end_ != OMIT
99
+ @max_participants = max_participants
100
+ @run_unit = run_unit if run_unit != OMIT
101
+ @run_interval = run_interval
102
+ @additional_properties = additional_properties
103
+ @_field_set = {
104
+ "history": history,
105
+ "rank": rank,
106
+ "value": value,
107
+ "id": id,
108
+ "name": name,
109
+ "key": key,
110
+ "rankBy": rank_by,
111
+ "metricKey": metric_key,
112
+ "metricName": metric_name,
113
+ "pointsSystemKey": points_system_key,
114
+ "pointsSystemName": points_system_name,
115
+ "description": description,
116
+ "start": start,
117
+ "end": end_,
118
+ "maxParticipants": max_participants,
119
+ "runUnit": run_unit,
120
+ "runInterval": run_interval
121
+ }.reject do |_k, v|
122
+ v == OMIT
123
+ end
124
+ end
125
+
126
+ # Deserialize a JSON object to an instance of UserLeaderboardResponseWithHistory
127
+ #
128
+ # @param json_object [String]
129
+ # @return [TrophyApiClient::UserLeaderboardResponseWithHistory]
130
+ def self.from_json(json_object:)
131
+ struct = JSON.parse(json_object, object_class: OpenStruct)
132
+ parsed_json = JSON.parse(json_object)
133
+ history = parsed_json["history"]&.map do |item|
134
+ item = item.to_json
135
+ TrophyApiClient::LeaderboardEvent.from_json(json_object: item)
136
+ end
137
+ rank = parsed_json["rank"]
138
+ value = parsed_json["value"]
139
+ id = parsed_json["id"]
140
+ name = parsed_json["name"]
141
+ key = parsed_json["key"]
142
+ rank_by = parsed_json["rankBy"]
143
+ metric_key = parsed_json["metricKey"]
144
+ metric_name = parsed_json["metricName"]
145
+ points_system_key = parsed_json["pointsSystemKey"]
146
+ points_system_name = parsed_json["pointsSystemName"]
147
+ description = parsed_json["description"]
148
+ start = parsed_json["start"]
149
+ end_ = parsed_json["end"]
150
+ max_participants = parsed_json["maxParticipants"]
151
+ run_unit = parsed_json["runUnit"]
152
+ run_interval = parsed_json["runInterval"]
153
+ new(
154
+ history: history,
155
+ rank: rank,
156
+ value: value,
157
+ id: id,
158
+ name: name,
159
+ key: key,
160
+ rank_by: rank_by,
161
+ metric_key: metric_key,
162
+ metric_name: metric_name,
163
+ points_system_key: points_system_key,
164
+ points_system_name: points_system_name,
165
+ description: description,
166
+ start: start,
167
+ end_: end_,
168
+ max_participants: max_participants,
169
+ run_unit: run_unit,
170
+ run_interval: run_interval,
171
+ additional_properties: struct
172
+ )
173
+ end
174
+
175
+ # Serialize an instance of UserLeaderboardResponseWithHistory to a JSON object
176
+ #
177
+ # @return [String]
178
+ def to_json(*_args)
179
+ @_field_set&.to_json
180
+ end
181
+
182
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
183
+ # hash and check each fields type against the current object's property
184
+ # definitions.
185
+ #
186
+ # @param obj [Object]
187
+ # @return [Void]
188
+ def self.validate_raw(obj:)
189
+ obj.history.is_a?(Array) != false || raise("Passed value for field obj.history is not the expected type, validation failed.")
190
+ obj.rank&.is_a?(Integer) != false || raise("Passed value for field obj.rank is not the expected type, validation failed.")
191
+ obj.value&.is_a?(Integer) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
192
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
193
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
194
+ obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
195
+ obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
196
+ obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
197
+ obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
198
+ obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.")
199
+ obj.points_system_name&.is_a?(String) != false || raise("Passed value for field obj.points_system_name is not the expected type, validation failed.")
200
+ obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
201
+ obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
202
+ obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
203
+ obj.max_participants.is_a?(Integer) != false || raise("Passed value for field obj.max_participants is not the expected type, validation failed.")
204
+ obj.run_unit&.is_a?(TrophyApiClient::LeaderboardResponseRunUnit) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.")
205
+ obj.run_interval.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.")
206
+ end
207
+ end
208
+ end
@@ -0,0 +1,212 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "leaderboard_response_rank_by"
4
+ require_relative "leaderboard_response_run_unit"
5
+ require "ostruct"
6
+ require "json"
7
+
8
+ module TrophyApiClient
9
+ # A user's data for a specific leaderboard including rank, value, and history.
10
+ class WebhookUserLeaderboardResponse
11
+ # @return [Integer] The user's rank before this event, or null if they were not on the leaderboard.
12
+ attr_reader :previous_rank
13
+ # @return [Integer] The user's value before this event, or null if they were not on the leaderboard.
14
+ attr_reader :previous_value
15
+ # @return [Integer] The user's current rank in this leaderboard. Null if the user is not on the
16
+ # leaderboard.
17
+ attr_reader :rank
18
+ # @return [Integer] The user's current value in this leaderboard. Null if the user is not on the
19
+ # leaderboard.
20
+ attr_reader :value
21
+ # @return [String] The unique ID of the leaderboard.
22
+ attr_reader :id
23
+ # @return [String] The user-facing name of the leaderboard.
24
+ attr_reader :name
25
+ # @return [String] The unique key used to reference the leaderboard in APIs.
26
+ attr_reader :key
27
+ # @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
28
+ attr_reader :rank_by
29
+ # @return [String] The key of the metric to rank by, if rankBy is 'metric'.
30
+ attr_reader :metric_key
31
+ # @return [String] The name of the metric to rank by, if rankBy is 'metric'.
32
+ attr_reader :metric_name
33
+ # @return [String] The key of the points system to rank by, if rankBy is 'points'.
34
+ attr_reader :points_system_key
35
+ # @return [String] The name of the points system to rank by, if rankBy is 'points'.
36
+ attr_reader :points_system_name
37
+ # @return [String] The user-facing description of the leaderboard.
38
+ attr_reader :description
39
+ # @return [String] The start date of the leaderboard in YYYY-MM-DD format.
40
+ attr_reader :start
41
+ # @return [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
42
+ # forever.
43
+ attr_reader :end_
44
+ # @return [Integer] The maximum number of participants in the leaderboard.
45
+ attr_reader :max_participants
46
+ # @return [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time
47
+ # leaderboards.
48
+ attr_reader :run_unit
49
+ # @return [Integer] The interval between repetitions, relative to the start date and repetition
50
+ # type.
51
+ attr_reader :run_interval
52
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
53
+ attr_reader :additional_properties
54
+ # @return [Object]
55
+ attr_reader :_field_set
56
+ protected :_field_set
57
+
58
+ OMIT = Object.new
59
+
60
+ # @param previous_rank [Integer] The user's rank before this event, or null if they were not on the leaderboard.
61
+ # @param previous_value [Integer] The user's value before this event, or null if they were not on the leaderboard.
62
+ # @param rank [Integer] The user's current rank in this leaderboard. Null if the user is not on the
63
+ # leaderboard.
64
+ # @param value [Integer] The user's current value in this leaderboard. Null if the user is not on the
65
+ # leaderboard.
66
+ # @param id [String] The unique ID of the leaderboard.
67
+ # @param name [String] The user-facing name of the leaderboard.
68
+ # @param key [String] The unique key used to reference the leaderboard in APIs.
69
+ # @param rank_by [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
70
+ # @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
71
+ # @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
72
+ # @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
73
+ # @param points_system_name [String] The name of the points system to rank by, if rankBy is 'points'.
74
+ # @param description [String] The user-facing description of the leaderboard.
75
+ # @param start [String] The start date of the leaderboard in YYYY-MM-DD format.
76
+ # @param end_ [String] The end date of the leaderboard in YYYY-MM-DD format, or null if it runs
77
+ # forever.
78
+ # @param max_participants [Integer] The maximum number of participants in the leaderboard.
79
+ # @param run_unit [TrophyApiClient::LeaderboardResponseRunUnit] The repetition type for recurring leaderboards, or null for one-time
80
+ # leaderboards.
81
+ # @param run_interval [Integer] The interval between repetitions, relative to the start date and repetition
82
+ # type.
83
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
84
+ # @return [TrophyApiClient::WebhookUserLeaderboardResponse]
85
+ def initialize(id:, name:, key:, rank_by:, description:, start:, max_participants:, run_interval:, previous_rank: OMIT, previous_value: OMIT, rank: OMIT, value: OMIT,
86
+ metric_key: OMIT, metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, end_: OMIT, run_unit: OMIT, additional_properties: nil)
87
+ @previous_rank = previous_rank if previous_rank != OMIT
88
+ @previous_value = previous_value if previous_value != OMIT
89
+ @rank = rank if rank != OMIT
90
+ @value = value if value != OMIT
91
+ @id = id
92
+ @name = name
93
+ @key = key
94
+ @rank_by = rank_by
95
+ @metric_key = metric_key if metric_key != OMIT
96
+ @metric_name = metric_name if metric_name != OMIT
97
+ @points_system_key = points_system_key if points_system_key != OMIT
98
+ @points_system_name = points_system_name if points_system_name != OMIT
99
+ @description = description
100
+ @start = start
101
+ @end_ = end_ if end_ != OMIT
102
+ @max_participants = max_participants
103
+ @run_unit = run_unit if run_unit != OMIT
104
+ @run_interval = run_interval
105
+ @additional_properties = additional_properties
106
+ @_field_set = {
107
+ "previousRank": previous_rank,
108
+ "previousValue": previous_value,
109
+ "rank": rank,
110
+ "value": value,
111
+ "id": id,
112
+ "name": name,
113
+ "key": key,
114
+ "rankBy": rank_by,
115
+ "metricKey": metric_key,
116
+ "metricName": metric_name,
117
+ "pointsSystemKey": points_system_key,
118
+ "pointsSystemName": points_system_name,
119
+ "description": description,
120
+ "start": start,
121
+ "end": end_,
122
+ "maxParticipants": max_participants,
123
+ "runUnit": run_unit,
124
+ "runInterval": run_interval
125
+ }.reject do |_k, v|
126
+ v == OMIT
127
+ end
128
+ end
129
+
130
+ # Deserialize a JSON object to an instance of WebhookUserLeaderboardResponse
131
+ #
132
+ # @param json_object [String]
133
+ # @return [TrophyApiClient::WebhookUserLeaderboardResponse]
134
+ def self.from_json(json_object:)
135
+ struct = JSON.parse(json_object, object_class: OpenStruct)
136
+ parsed_json = JSON.parse(json_object)
137
+ previous_rank = parsed_json["previousRank"]
138
+ previous_value = parsed_json["previousValue"]
139
+ rank = parsed_json["rank"]
140
+ value = parsed_json["value"]
141
+ id = parsed_json["id"]
142
+ name = parsed_json["name"]
143
+ key = parsed_json["key"]
144
+ rank_by = parsed_json["rankBy"]
145
+ metric_key = parsed_json["metricKey"]
146
+ metric_name = parsed_json["metricName"]
147
+ points_system_key = parsed_json["pointsSystemKey"]
148
+ points_system_name = parsed_json["pointsSystemName"]
149
+ description = parsed_json["description"]
150
+ start = parsed_json["start"]
151
+ end_ = parsed_json["end"]
152
+ max_participants = parsed_json["maxParticipants"]
153
+ run_unit = parsed_json["runUnit"]
154
+ run_interval = parsed_json["runInterval"]
155
+ new(
156
+ previous_rank: previous_rank,
157
+ previous_value: previous_value,
158
+ rank: rank,
159
+ value: value,
160
+ id: id,
161
+ name: name,
162
+ key: key,
163
+ rank_by: rank_by,
164
+ metric_key: metric_key,
165
+ metric_name: metric_name,
166
+ points_system_key: points_system_key,
167
+ points_system_name: points_system_name,
168
+ description: description,
169
+ start: start,
170
+ end_: end_,
171
+ max_participants: max_participants,
172
+ run_unit: run_unit,
173
+ run_interval: run_interval,
174
+ additional_properties: struct
175
+ )
176
+ end
177
+
178
+ # Serialize an instance of WebhookUserLeaderboardResponse to a JSON object
179
+ #
180
+ # @return [String]
181
+ def to_json(*_args)
182
+ @_field_set&.to_json
183
+ end
184
+
185
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
186
+ # hash and check each fields type against the current object's property
187
+ # definitions.
188
+ #
189
+ # @param obj [Object]
190
+ # @return [Void]
191
+ def self.validate_raw(obj:)
192
+ obj.previous_rank&.is_a?(Integer) != false || raise("Passed value for field obj.previous_rank is not the expected type, validation failed.")
193
+ obj.previous_value&.is_a?(Integer) != false || raise("Passed value for field obj.previous_value is not the expected type, validation failed.")
194
+ obj.rank&.is_a?(Integer) != false || raise("Passed value for field obj.rank is not the expected type, validation failed.")
195
+ obj.value&.is_a?(Integer) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
196
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
197
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
198
+ obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
199
+ obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
200
+ obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
201
+ obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
202
+ obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.")
203
+ obj.points_system_name&.is_a?(String) != false || raise("Passed value for field obj.points_system_name is not the expected type, validation failed.")
204
+ obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
205
+ obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
206
+ obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
207
+ obj.max_participants.is_a?(Integer) != false || raise("Passed value for field obj.max_participants is not the expected type, validation failed.")
208
+ obj.run_unit&.is_a?(TrophyApiClient::LeaderboardResponseRunUnit) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.")
209
+ obj.run_interval.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.")
210
+ end
211
+ end
212
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "user"
4
+ require_relative "completed_achievement_response"
5
+ require "ostruct"
6
+ require "json"
7
+
8
+ module TrophyApiClient
9
+ class WebhooksAchievementCompletedPayload
10
+ # @return [String] The webhook event type.
11
+ attr_reader :type
12
+ # @return [TrophyApiClient::User] The user who completed the achievement.
13
+ attr_reader :user
14
+ # @return [TrophyApiClient::CompletedAchievementResponse] The achievement completion that occurred.
15
+ attr_reader :achievement
16
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
17
+ attr_reader :additional_properties
18
+ # @return [Object]
19
+ attr_reader :_field_set
20
+ protected :_field_set
21
+
22
+ OMIT = Object.new
23
+
24
+ # @param type [String] The webhook event type.
25
+ # @param user [TrophyApiClient::User] The user who completed the achievement.
26
+ # @param achievement [TrophyApiClient::CompletedAchievementResponse] The achievement completion that occurred.
27
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
28
+ # @return [TrophyApiClient::WebhooksAchievementCompletedPayload]
29
+ def initialize(type:, user:, achievement:, additional_properties: nil)
30
+ @type = type
31
+ @user = user
32
+ @achievement = achievement
33
+ @additional_properties = additional_properties
34
+ @_field_set = { "type": type, "user": user, "achievement": achievement }
35
+ end
36
+
37
+ # Deserialize a JSON object to an instance of WebhooksAchievementCompletedPayload
38
+ #
39
+ # @param json_object [String]
40
+ # @return [TrophyApiClient::WebhooksAchievementCompletedPayload]
41
+ def self.from_json(json_object:)
42
+ struct = JSON.parse(json_object, object_class: OpenStruct)
43
+ parsed_json = JSON.parse(json_object)
44
+ type = parsed_json["type"]
45
+ if parsed_json["user"].nil?
46
+ user = nil
47
+ else
48
+ user = parsed_json["user"].to_json
49
+ user = TrophyApiClient::User.from_json(json_object: user)
50
+ end
51
+ if parsed_json["achievement"].nil?
52
+ achievement = nil
53
+ else
54
+ achievement = parsed_json["achievement"].to_json
55
+ achievement = TrophyApiClient::CompletedAchievementResponse.from_json(json_object: achievement)
56
+ end
57
+ new(
58
+ type: type,
59
+ user: user,
60
+ achievement: achievement,
61
+ additional_properties: struct
62
+ )
63
+ end
64
+
65
+ # Serialize an instance of WebhooksAchievementCompletedPayload to a JSON object
66
+ #
67
+ # @return [String]
68
+ def to_json(*_args)
69
+ @_field_set&.to_json
70
+ end
71
+
72
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
73
+ # hash and check each fields type against the current object's property
74
+ # definitions.
75
+ #
76
+ # @param obj [Object]
77
+ # @return [Void]
78
+ def self.validate_raw(obj:)
79
+ obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
80
+ TrophyApiClient::User.validate_raw(obj: obj.user)
81
+ TrophyApiClient::CompletedAchievementResponse.validate_raw(obj: obj.achievement)
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "leaderboard_response_with_rankings"
4
+ require "ostruct"
5
+ require "json"
6
+
7
+ module TrophyApiClient
8
+ class WebhooksLeaderboardChangedPayload
9
+ # @return [String] The webhook event type.
10
+ attr_reader :type
11
+ # @return [TrophyApiClient::LeaderboardResponseWithRankings] The leaderboard run that changed.
12
+ attr_reader :leaderboard
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 type [String] The webhook event type.
22
+ # @param leaderboard [TrophyApiClient::LeaderboardResponseWithRankings] The leaderboard run that changed.
23
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
24
+ # @return [TrophyApiClient::WebhooksLeaderboardChangedPayload]
25
+ def initialize(type:, leaderboard:, additional_properties: nil)
26
+ @type = type
27
+ @leaderboard = leaderboard
28
+ @additional_properties = additional_properties
29
+ @_field_set = { "type": type, "leaderboard": leaderboard }
30
+ end
31
+
32
+ # Deserialize a JSON object to an instance of WebhooksLeaderboardChangedPayload
33
+ #
34
+ # @param json_object [String]
35
+ # @return [TrophyApiClient::WebhooksLeaderboardChangedPayload]
36
+ def self.from_json(json_object:)
37
+ struct = JSON.parse(json_object, object_class: OpenStruct)
38
+ parsed_json = JSON.parse(json_object)
39
+ type = parsed_json["type"]
40
+ if parsed_json["leaderboard"].nil?
41
+ leaderboard = nil
42
+ else
43
+ leaderboard = parsed_json["leaderboard"].to_json
44
+ leaderboard = TrophyApiClient::LeaderboardResponseWithRankings.from_json(json_object: leaderboard)
45
+ end
46
+ new(
47
+ type: type,
48
+ leaderboard: leaderboard,
49
+ additional_properties: struct
50
+ )
51
+ end
52
+
53
+ # Serialize an instance of WebhooksLeaderboardChangedPayload 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
+ obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
68
+ TrophyApiClient::LeaderboardResponseWithRankings.validate_raw(obj: obj.leaderboard)
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "leaderboard_response_with_rankings"
4
+ require "ostruct"
5
+ require "json"
6
+
7
+ module TrophyApiClient
8
+ class WebhooksLeaderboardFinishedPayload
9
+ # @return [String] The webhook event type.
10
+ attr_reader :type
11
+ # @return [TrophyApiClient::LeaderboardResponseWithRankings] The leaderboard run that finished and its final rankings.
12
+ attr_reader :leaderboard
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 type [String] The webhook event type.
22
+ # @param leaderboard [TrophyApiClient::LeaderboardResponseWithRankings] The leaderboard run that finished and its final rankings.
23
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
24
+ # @return [TrophyApiClient::WebhooksLeaderboardFinishedPayload]
25
+ def initialize(type:, leaderboard:, additional_properties: nil)
26
+ @type = type
27
+ @leaderboard = leaderboard
28
+ @additional_properties = additional_properties
29
+ @_field_set = { "type": type, "leaderboard": leaderboard }
30
+ end
31
+
32
+ # Deserialize a JSON object to an instance of WebhooksLeaderboardFinishedPayload
33
+ #
34
+ # @param json_object [String]
35
+ # @return [TrophyApiClient::WebhooksLeaderboardFinishedPayload]
36
+ def self.from_json(json_object:)
37
+ struct = JSON.parse(json_object, object_class: OpenStruct)
38
+ parsed_json = JSON.parse(json_object)
39
+ type = parsed_json["type"]
40
+ if parsed_json["leaderboard"].nil?
41
+ leaderboard = nil
42
+ else
43
+ leaderboard = parsed_json["leaderboard"].to_json
44
+ leaderboard = TrophyApiClient::LeaderboardResponseWithRankings.from_json(json_object: leaderboard)
45
+ end
46
+ new(
47
+ type: type,
48
+ leaderboard: leaderboard,
49
+ additional_properties: struct
50
+ )
51
+ end
52
+
53
+ # Serialize an instance of WebhooksLeaderboardFinishedPayload 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
+ obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
68
+ TrophyApiClient::LeaderboardResponseWithRankings.validate_raw(obj: obj.leaderboard)
69
+ end
70
+ end
71
+ end