trophy_api_client 1.6.0 → 1.8.0

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 (101) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gemconfig.rb +1 -1
  3. data/lib/trophy_api_client/admin/attributes/client.rb +6 -6
  4. data/lib/trophy_api_client/admin/client.rb +14 -7
  5. data/lib/trophy_api_client/admin/leaderboards/client.rb +371 -0
  6. data/lib/trophy_api_client/admin/metrics/client.rb +6 -6
  7. data/lib/trophy_api_client/admin/points/boosts/client.rb +258 -39
  8. data/lib/trophy_api_client/admin/points/client.rb +21 -0
  9. data/lib/trophy_api_client/admin/points/levels/client.rb +402 -0
  10. data/lib/trophy_api_client/admin/points/systems/client.rb +374 -0
  11. data/lib/trophy_api_client/admin/points/triggers/client.rb +402 -0
  12. data/lib/trophy_api_client/types/admin_leaderboard.rb +171 -0
  13. data/lib/trophy_api_client/types/admin_leaderboard_rank_by.rb +10 -0
  14. data/lib/trophy_api_client/types/admin_leaderboard_run_unit.rb +10 -0
  15. data/lib/trophy_api_client/types/admin_leaderboard_status.rb +11 -0
  16. data/lib/trophy_api_client/types/{created_points_boost.rb → admin_points_boost.rb} +39 -23
  17. data/lib/trophy_api_client/types/{created_points_boost_rounding.rb → admin_points_boost_rounding.rb} +1 -1
  18. data/lib/trophy_api_client/types/{created_points_boost_status.rb → admin_points_boost_status.rb} +1 -1
  19. data/lib/trophy_api_client/types/admin_points_boost_user_attributes_item.rb +65 -0
  20. data/lib/trophy_api_client/types/admin_points_level.rb +109 -0
  21. data/lib/trophy_api_client/types/admin_points_level_badge.rb +55 -0
  22. data/lib/trophy_api_client/types/admin_points_system.rb +118 -0
  23. data/lib/trophy_api_client/types/admin_points_system_badge.rb +55 -0
  24. data/lib/trophy_api_client/types/admin_points_system_status.rb +9 -0
  25. data/lib/trophy_api_client/types/admin_points_trigger.rb +175 -0
  26. data/lib/trophy_api_client/types/admin_points_trigger_event_attributes_item.rb +66 -0
  27. data/lib/trophy_api_client/types/admin_points_trigger_status.rb +9 -0
  28. data/lib/trophy_api_client/types/admin_points_trigger_time_unit.rb +9 -0
  29. data/lib/trophy_api_client/types/admin_points_trigger_type.rb +12 -0
  30. data/lib/trophy_api_client/types/admin_points_trigger_user_attributes_item.rb +65 -0
  31. data/lib/trophy_api_client/types/create_leaderboard_request_item.rb +171 -0
  32. data/lib/trophy_api_client/types/create_leaderboard_request_item_rank_by.rb +10 -0
  33. data/lib/trophy_api_client/types/create_leaderboard_request_item_run_unit.rb +11 -0
  34. data/lib/trophy_api_client/types/create_leaderboard_request_item_status.rb +13 -0
  35. data/lib/trophy_api_client/types/create_leaderboards_request.rb +7 -0
  36. data/lib/trophy_api_client/types/create_leaderboards_response.rb +74 -0
  37. data/lib/trophy_api_client/types/create_points_boost_request_item.rb +125 -0
  38. data/lib/trophy_api_client/types/create_points_boost_request_item_rounding.rb +10 -0
  39. data/lib/trophy_api_client/types/create_points_boost_request_item_user_attributes_item.rb +67 -0
  40. data/lib/trophy_api_client/types/create_points_boosts_request.rb +7 -0
  41. data/lib/trophy_api_client/types/create_points_boosts_response.rb +4 -4
  42. data/lib/trophy_api_client/types/create_points_level_request_item.rb +103 -0
  43. data/lib/trophy_api_client/types/create_points_level_request_item_badge.rb +56 -0
  44. data/lib/trophy_api_client/types/create_points_levels_request.rb +7 -0
  45. data/lib/trophy_api_client/types/create_points_levels_response.rb +74 -0
  46. data/lib/trophy_api_client/types/create_points_system_request_item.rb +140 -0
  47. data/lib/trophy_api_client/types/create_points_system_request_item_badge.rb +55 -0
  48. data/lib/trophy_api_client/types/create_points_systems_request.rb +7 -0
  49. data/lib/trophy_api_client/types/create_points_systems_response.rb +74 -0
  50. data/lib/trophy_api_client/types/create_points_trigger_request_item.rb +167 -0
  51. data/lib/trophy_api_client/types/create_points_trigger_request_item_event_attributes_item.rb +67 -0
  52. data/lib/trophy_api_client/types/create_points_trigger_request_item_status.rb +9 -0
  53. data/lib/trophy_api_client/types/create_points_trigger_request_item_time_unit.rb +9 -0
  54. data/lib/trophy_api_client/types/create_points_trigger_request_item_type.rb +12 -0
  55. data/lib/trophy_api_client/types/create_points_trigger_request_item_user_attributes_item.rb +67 -0
  56. data/lib/trophy_api_client/types/create_points_triggers_request.rb +7 -0
  57. data/lib/trophy_api_client/types/create_points_triggers_response.rb +74 -0
  58. data/lib/trophy_api_client/types/created_admin_points_system.rb +163 -0
  59. data/lib/trophy_api_client/types/delete_leaderboards_response.rb +75 -0
  60. data/lib/trophy_api_client/types/delete_points_levels_response.rb +74 -0
  61. data/lib/trophy_api_client/types/delete_points_systems_response.rb +74 -0
  62. data/lib/trophy_api_client/types/delete_points_triggers_response.rb +75 -0
  63. data/lib/trophy_api_client/types/list_leaderboards_response.rb +7 -0
  64. data/lib/trophy_api_client/types/list_points_boosts_response.rb +7 -0
  65. data/lib/trophy_api_client/types/list_points_levels_response.rb +7 -0
  66. data/lib/trophy_api_client/types/list_points_systems_response.rb +7 -0
  67. data/lib/trophy_api_client/types/list_points_triggers_response.rb +7 -0
  68. data/lib/trophy_api_client/types/patch_points_boosts_request.rb +7 -0
  69. data/lib/trophy_api_client/types/patch_points_boosts_request_item.rb +118 -0
  70. data/lib/trophy_api_client/types/patch_points_boosts_request_item_rounding.rb +10 -0
  71. data/lib/trophy_api_client/types/patch_points_boosts_request_item_user_attributes_item.rb +67 -0
  72. data/lib/trophy_api_client/types/patch_points_boosts_response.rb +74 -0
  73. data/lib/trophy_api_client/types/patch_points_levels_request.rb +7 -0
  74. data/lib/trophy_api_client/types/patch_points_levels_request_item.rb +100 -0
  75. data/lib/trophy_api_client/types/patch_points_levels_request_item_badge.rb +55 -0
  76. data/lib/trophy_api_client/types/patch_points_levels_response.rb +74 -0
  77. data/lib/trophy_api_client/types/patch_points_triggers_request.rb +7 -0
  78. data/lib/trophy_api_client/types/patch_points_triggers_request_item.rb +174 -0
  79. data/lib/trophy_api_client/types/patch_points_triggers_request_item_event_attributes_item.rb +67 -0
  80. data/lib/trophy_api_client/types/patch_points_triggers_request_item_status.rb +9 -0
  81. data/lib/trophy_api_client/types/patch_points_triggers_request_item_time_unit.rb +9 -0
  82. data/lib/trophy_api_client/types/patch_points_triggers_request_item_type.rb +13 -0
  83. data/lib/trophy_api_client/types/patch_points_triggers_request_item_user_attributes_item.rb +67 -0
  84. data/lib/trophy_api_client/types/patch_points_triggers_response.rb +74 -0
  85. data/lib/trophy_api_client/types/update_leaderboard_request_item.rb +179 -0
  86. data/lib/trophy_api_client/types/update_leaderboard_request_item_rank_by.rb +11 -0
  87. data/lib/trophy_api_client/types/update_leaderboard_request_item_run_unit.rb +9 -0
  88. data/lib/trophy_api_client/types/update_leaderboard_request_item_status.rb +12 -0
  89. data/lib/trophy_api_client/types/update_leaderboards_request.rb +7 -0
  90. data/lib/trophy_api_client/types/update_leaderboards_response.rb +75 -0
  91. data/lib/trophy_api_client/types/update_points_system_request_item.rb +102 -0
  92. data/lib/trophy_api_client/types/update_points_system_request_item_badge.rb +55 -0
  93. data/lib/trophy_api_client/types/update_points_systems_request.rb +7 -0
  94. data/lib/trophy_api_client/types/update_points_systems_response.rb +74 -0
  95. data/lib/trophy_api_client/users/client.rb +2 -2
  96. data/lib/trophy_api_client/version.rb +1 -1
  97. data/lib/types_export.rb +93 -17
  98. metadata +87 -7
  99. data/lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item.rb +0 -111
  100. data/lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item_rounding.rb +0 -16
  101. data/lib/trophy_api_client/types/notification_type.rb +0 -11
@@ -0,0 +1,175 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "admin_points_trigger_type"
4
+ require_relative "admin_points_trigger_status"
5
+ require_relative "admin_points_trigger_user_attributes_item"
6
+ require_relative "admin_points_trigger_event_attributes_item"
7
+ require_relative "admin_points_trigger_time_unit"
8
+ require "ostruct"
9
+ require "json"
10
+
11
+ module TrophyApiClient
12
+ # A points trigger as returned from admin endpoints.
13
+ class AdminPointsTrigger
14
+ # @return [String] The UUID of the trigger.
15
+ attr_reader :id
16
+ # @return [TrophyApiClient::AdminPointsTriggerType] The type of trigger.
17
+ attr_reader :type
18
+ # @return [Integer] The number of points awarded or deducted when the trigger fires.
19
+ attr_reader :points
20
+ # @return [TrophyApiClient::AdminPointsTriggerStatus] The status of the trigger.
21
+ attr_reader :status
22
+ # @return [Array<TrophyApiClient::AdminPointsTriggerUserAttributesItem>] User attribute filters applied to the trigger.
23
+ attr_reader :user_attributes
24
+ # @return [String] The UUID of the metric. Only present for metric triggers.
25
+ attr_reader :metric_id
26
+ # @return [Integer] The metric threshold. Only present for metric triggers.
27
+ attr_reader :metric_threshold
28
+ # @return [Array<TrophyApiClient::AdminPointsTriggerEventAttributesItem>] Event attribute filters applied to the trigger. Only present for metric
29
+ # triggers.
30
+ attr_reader :event_attributes
31
+ # @return [String] The UUID of the achievement. Only present for achievement triggers.
32
+ attr_reader :achievement_id
33
+ # @return [Integer] The streak length. Only present for streak triggers.
34
+ attr_reader :streak_length
35
+ # @return [TrophyApiClient::AdminPointsTriggerTimeUnit] The time unit. Only present for time triggers.
36
+ attr_reader :time_unit
37
+ # @return [Integer] The time interval. Only present for time triggers.
38
+ attr_reader :time_interval
39
+ # @return [Boolean] Whether metric events that would reduce the user's points below zero are
40
+ # blocked.
41
+ attr_reader :block_if_out_of_points
42
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
43
+ attr_reader :additional_properties
44
+ # @return [Object]
45
+ attr_reader :_field_set
46
+ protected :_field_set
47
+
48
+ OMIT = Object.new
49
+
50
+ # @param id [String] The UUID of the trigger.
51
+ # @param type [TrophyApiClient::AdminPointsTriggerType] The type of trigger.
52
+ # @param points [Integer] The number of points awarded or deducted when the trigger fires.
53
+ # @param status [TrophyApiClient::AdminPointsTriggerStatus] The status of the trigger.
54
+ # @param user_attributes [Array<TrophyApiClient::AdminPointsTriggerUserAttributesItem>] User attribute filters applied to the trigger.
55
+ # @param metric_id [String] The UUID of the metric. Only present for metric triggers.
56
+ # @param metric_threshold [Integer] The metric threshold. Only present for metric triggers.
57
+ # @param event_attributes [Array<TrophyApiClient::AdminPointsTriggerEventAttributesItem>] Event attribute filters applied to the trigger. Only present for metric
58
+ # triggers.
59
+ # @param achievement_id [String] The UUID of the achievement. Only present for achievement triggers.
60
+ # @param streak_length [Integer] The streak length. Only present for streak triggers.
61
+ # @param time_unit [TrophyApiClient::AdminPointsTriggerTimeUnit] The time unit. Only present for time triggers.
62
+ # @param time_interval [Integer] The time interval. Only present for time triggers.
63
+ # @param block_if_out_of_points [Boolean] Whether metric events that would reduce the user's points below zero are
64
+ # blocked.
65
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
66
+ # @return [TrophyApiClient::AdminPointsTrigger]
67
+ def initialize(id:, type:, points:, status:, user_attributes:, block_if_out_of_points:, metric_id: OMIT, metric_threshold: OMIT,
68
+ event_attributes: OMIT, achievement_id: OMIT, streak_length: OMIT, time_unit: OMIT, time_interval: OMIT, additional_properties: nil)
69
+ @id = id
70
+ @type = type
71
+ @points = points
72
+ @status = status
73
+ @user_attributes = user_attributes
74
+ @metric_id = metric_id if metric_id != OMIT
75
+ @metric_threshold = metric_threshold if metric_threshold != OMIT
76
+ @event_attributes = event_attributes if event_attributes != OMIT
77
+ @achievement_id = achievement_id if achievement_id != OMIT
78
+ @streak_length = streak_length if streak_length != OMIT
79
+ @time_unit = time_unit if time_unit != OMIT
80
+ @time_interval = time_interval if time_interval != OMIT
81
+ @block_if_out_of_points = block_if_out_of_points
82
+ @additional_properties = additional_properties
83
+ @_field_set = {
84
+ "id": id,
85
+ "type": type,
86
+ "points": points,
87
+ "status": status,
88
+ "userAttributes": user_attributes,
89
+ "metricId": metric_id,
90
+ "metricThreshold": metric_threshold,
91
+ "eventAttributes": event_attributes,
92
+ "achievementId": achievement_id,
93
+ "streakLength": streak_length,
94
+ "timeUnit": time_unit,
95
+ "timeInterval": time_interval,
96
+ "blockIfOutOfPoints": block_if_out_of_points
97
+ }.reject do |_k, v|
98
+ v == OMIT
99
+ end
100
+ end
101
+
102
+ # Deserialize a JSON object to an instance of AdminPointsTrigger
103
+ #
104
+ # @param json_object [String]
105
+ # @return [TrophyApiClient::AdminPointsTrigger]
106
+ def self.from_json(json_object:)
107
+ struct = JSON.parse(json_object, object_class: OpenStruct)
108
+ parsed_json = JSON.parse(json_object)
109
+ id = parsed_json["id"]
110
+ type = parsed_json["type"]
111
+ points = parsed_json["points"]
112
+ status = parsed_json["status"]
113
+ user_attributes = parsed_json["userAttributes"]&.map do |item|
114
+ item = item.to_json
115
+ TrophyApiClient::AdminPointsTriggerUserAttributesItem.from_json(json_object: item)
116
+ end
117
+ metric_id = parsed_json["metricId"]
118
+ metric_threshold = parsed_json["metricThreshold"]
119
+ event_attributes = parsed_json["eventAttributes"]&.map do |item|
120
+ item = item.to_json
121
+ TrophyApiClient::AdminPointsTriggerEventAttributesItem.from_json(json_object: item)
122
+ end
123
+ achievement_id = parsed_json["achievementId"]
124
+ streak_length = parsed_json["streakLength"]
125
+ time_unit = parsed_json["timeUnit"]
126
+ time_interval = parsed_json["timeInterval"]
127
+ block_if_out_of_points = parsed_json["blockIfOutOfPoints"]
128
+ new(
129
+ id: id,
130
+ type: type,
131
+ points: points,
132
+ status: status,
133
+ user_attributes: user_attributes,
134
+ metric_id: metric_id,
135
+ metric_threshold: metric_threshold,
136
+ event_attributes: event_attributes,
137
+ achievement_id: achievement_id,
138
+ streak_length: streak_length,
139
+ time_unit: time_unit,
140
+ time_interval: time_interval,
141
+ block_if_out_of_points: block_if_out_of_points,
142
+ additional_properties: struct
143
+ )
144
+ end
145
+
146
+ # Serialize an instance of AdminPointsTrigger to a JSON object
147
+ #
148
+ # @return [String]
149
+ def to_json(*_args)
150
+ @_field_set&.to_json
151
+ end
152
+
153
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
154
+ # hash and check each fields type against the current object's property
155
+ # definitions.
156
+ #
157
+ # @param obj [Object]
158
+ # @return [Void]
159
+ def self.validate_raw(obj:)
160
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
161
+ obj.type.is_a?(TrophyApiClient::AdminPointsTriggerType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
162
+ obj.points.is_a?(Integer) != false || raise("Passed value for field obj.points is not the expected type, validation failed.")
163
+ obj.status.is_a?(TrophyApiClient::AdminPointsTriggerStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
164
+ obj.user_attributes.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.")
165
+ obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
166
+ obj.metric_threshold&.is_a?(Integer) != false || raise("Passed value for field obj.metric_threshold is not the expected type, validation failed.")
167
+ obj.event_attributes&.is_a?(Array) != false || raise("Passed value for field obj.event_attributes is not the expected type, validation failed.")
168
+ obj.achievement_id&.is_a?(String) != false || raise("Passed value for field obj.achievement_id is not the expected type, validation failed.")
169
+ obj.streak_length&.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.")
170
+ obj.time_unit&.is_a?(TrophyApiClient::AdminPointsTriggerTimeUnit) != false || raise("Passed value for field obj.time_unit is not the expected type, validation failed.")
171
+ obj.time_interval&.is_a?(Integer) != false || raise("Passed value for field obj.time_interval is not the expected type, validation failed.")
172
+ obj.block_if_out_of_points.is_a?(Boolean) != false || raise("Passed value for field obj.block_if_out_of_points is not the expected type, validation failed.")
173
+ end
174
+ end
175
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module TrophyApiClient
7
+ class AdminPointsTriggerEventAttributesItem
8
+ # @return [String]
9
+ attr_reader :attribute_id
10
+ # @return [String]
11
+ attr_reader :attribute_value
12
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
13
+ attr_reader :additional_properties
14
+ # @return [Object]
15
+ attr_reader :_field_set
16
+ protected :_field_set
17
+
18
+ OMIT = Object.new
19
+
20
+ # @param attribute_id [String]
21
+ # @param attribute_value [String]
22
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
23
+ # @return [TrophyApiClient::AdminPointsTriggerEventAttributesItem]
24
+ def initialize(attribute_id:, attribute_value:, additional_properties: nil)
25
+ @attribute_id = attribute_id
26
+ @attribute_value = attribute_value
27
+ @additional_properties = additional_properties
28
+ @_field_set = { "attributeId": attribute_id, "attributeValue": attribute_value }
29
+ end
30
+
31
+ # Deserialize a JSON object to an instance of
32
+ # AdminPointsTriggerEventAttributesItem
33
+ #
34
+ # @param json_object [String]
35
+ # @return [TrophyApiClient::AdminPointsTriggerEventAttributesItem]
36
+ def self.from_json(json_object:)
37
+ struct = JSON.parse(json_object, object_class: OpenStruct)
38
+ parsed_json = JSON.parse(json_object)
39
+ attribute_id = parsed_json["attributeId"]
40
+ attribute_value = parsed_json["attributeValue"]
41
+ new(
42
+ attribute_id: attribute_id,
43
+ attribute_value: attribute_value,
44
+ additional_properties: struct
45
+ )
46
+ end
47
+
48
+ # Serialize an instance of AdminPointsTriggerEventAttributesItem to a JSON object
49
+ #
50
+ # @return [String]
51
+ def to_json(*_args)
52
+ @_field_set&.to_json
53
+ end
54
+
55
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
56
+ # hash and check each fields type against the current object's property
57
+ # definitions.
58
+ #
59
+ # @param obj [Object]
60
+ # @return [Void]
61
+ def self.validate_raw(obj:)
62
+ obj.attribute_id.is_a?(String) != false || raise("Passed value for field obj.attribute_id is not the expected type, validation failed.")
63
+ obj.attribute_value.is_a?(String) != false || raise("Passed value for field obj.attribute_value is not the expected type, validation failed.")
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrophyApiClient
4
+ # The status of the trigger.
5
+ class AdminPointsTriggerStatus
6
+ ACTIVE = "active"
7
+ INACTIVE = "inactive"
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrophyApiClient
4
+ # The time unit. Only present for time triggers.
5
+ class AdminPointsTriggerTimeUnit
6
+ HOURS = "hours"
7
+ DAYS = "days"
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrophyApiClient
4
+ # The type of trigger.
5
+ class AdminPointsTriggerType
6
+ METRIC = "metric"
7
+ ACHIEVEMENT = "achievement"
8
+ STREAK = "streak"
9
+ TIME = "time"
10
+ USER_CREATION = "user_creation"
11
+ end
12
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module TrophyApiClient
7
+ class AdminPointsTriggerUserAttributesItem
8
+ # @return [String]
9
+ attr_reader :attribute_id
10
+ # @return [String]
11
+ attr_reader :attribute_value
12
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
13
+ attr_reader :additional_properties
14
+ # @return [Object]
15
+ attr_reader :_field_set
16
+ protected :_field_set
17
+
18
+ OMIT = Object.new
19
+
20
+ # @param attribute_id [String]
21
+ # @param attribute_value [String]
22
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
23
+ # @return [TrophyApiClient::AdminPointsTriggerUserAttributesItem]
24
+ def initialize(attribute_id:, attribute_value:, additional_properties: nil)
25
+ @attribute_id = attribute_id
26
+ @attribute_value = attribute_value
27
+ @additional_properties = additional_properties
28
+ @_field_set = { "attributeId": attribute_id, "attributeValue": attribute_value }
29
+ end
30
+
31
+ # Deserialize a JSON object to an instance of AdminPointsTriggerUserAttributesItem
32
+ #
33
+ # @param json_object [String]
34
+ # @return [TrophyApiClient::AdminPointsTriggerUserAttributesItem]
35
+ def self.from_json(json_object:)
36
+ struct = JSON.parse(json_object, object_class: OpenStruct)
37
+ parsed_json = JSON.parse(json_object)
38
+ attribute_id = parsed_json["attributeId"]
39
+ attribute_value = parsed_json["attributeValue"]
40
+ new(
41
+ attribute_id: attribute_id,
42
+ attribute_value: attribute_value,
43
+ additional_properties: struct
44
+ )
45
+ end
46
+
47
+ # Serialize an instance of AdminPointsTriggerUserAttributesItem to a JSON object
48
+ #
49
+ # @return [String]
50
+ def to_json(*_args)
51
+ @_field_set&.to_json
52
+ end
53
+
54
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
55
+ # hash and check each fields type against the current object's property
56
+ # definitions.
57
+ #
58
+ # @param obj [Object]
59
+ # @return [Void]
60
+ def self.validate_raw(obj:)
61
+ obj.attribute_id.is_a?(String) != false || raise("Passed value for field obj.attribute_id is not the expected type, validation failed.")
62
+ obj.attribute_value.is_a?(String) != false || raise("Passed value for field obj.attribute_value is not the expected type, validation failed.")
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,171 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "create_leaderboard_request_item_status"
4
+ require_relative "create_leaderboard_request_item_rank_by"
5
+ require_relative "create_leaderboard_request_item_run_unit"
6
+ require "ostruct"
7
+ require "json"
8
+
9
+ module TrophyApiClient
10
+ # A leaderboard to create.
11
+ class CreateLeaderboardRequestItem
12
+ # @return [String] The leaderboard name.
13
+ attr_reader :name
14
+ # @return [String] The leaderboard key. Only alphanumeric characters, hyphens, and underscores are
15
+ # permitted.
16
+ attr_reader :key
17
+ # @return [String] The leaderboard description.
18
+ attr_reader :description
19
+ # @return [TrophyApiClient::CreateLeaderboardRequestItemStatus] The initial user-facing status. Defaults to `inactive`. Use `scheduled` for
20
+ # leaderboards that should be active in the future and `finished` only when
21
+ # creating a leaderboard with an end date in the past.
22
+ attr_reader :status
23
+ # @return [TrophyApiClient::CreateLeaderboardRequestItemRankBy] What the leaderboard ranks by.
24
+ attr_reader :rank_by
25
+ # @return [String] The metric ID to rank by when `rankBy` is `metric`.
26
+ attr_reader :metric_id
27
+ # @return [String] The points system ID to rank by when `rankBy` is `points`.
28
+ attr_reader :points_system_id
29
+ # @return [Integer] The maximum number of participants. Defaults to `1000`.
30
+ attr_reader :max_participants
31
+ # @return [String] The leaderboard start date in YYYY-MM-DD format. Defaults to today when omitted.
32
+ attr_reader :start
33
+ # @return [String] The optional leaderboard end date in YYYY-MM-DD format.
34
+ attr_reader :end_
35
+ # @return [Array<String>] The UUIDs of the active user attributes to break rankings down by.
36
+ attr_reader :breakdown_attributes
37
+ # @return [TrophyApiClient::CreateLeaderboardRequestItemRunUnit] How often the leaderboard repeats. Omit for a non-recurring leaderboard. Streak
38
+ # leaderboards cannot repeat.
39
+ attr_reader :run_unit
40
+ # @return [Integer] The number of `runUnit`s between repeats. Required when `runUnit` is set.
41
+ attr_reader :run_interval
42
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
43
+ attr_reader :additional_properties
44
+ # @return [Object]
45
+ attr_reader :_field_set
46
+ protected :_field_set
47
+
48
+ OMIT = Object.new
49
+
50
+ # @param name [String] The leaderboard name.
51
+ # @param key [String] The leaderboard key. Only alphanumeric characters, hyphens, and underscores are
52
+ # permitted.
53
+ # @param description [String] The leaderboard description.
54
+ # @param status [TrophyApiClient::CreateLeaderboardRequestItemStatus] The initial user-facing status. Defaults to `inactive`. Use `scheduled` for
55
+ # leaderboards that should be active in the future and `finished` only when
56
+ # creating a leaderboard with an end date in the past.
57
+ # @param rank_by [TrophyApiClient::CreateLeaderboardRequestItemRankBy] What the leaderboard ranks by.
58
+ # @param metric_id [String] The metric ID to rank by when `rankBy` is `metric`.
59
+ # @param points_system_id [String] The points system ID to rank by when `rankBy` is `points`.
60
+ # @param max_participants [Integer] The maximum number of participants. Defaults to `1000`.
61
+ # @param start [String] The leaderboard start date in YYYY-MM-DD format. Defaults to today when omitted.
62
+ # @param end_ [String] The optional leaderboard end date in YYYY-MM-DD format.
63
+ # @param breakdown_attributes [Array<String>] The UUIDs of the active user attributes to break rankings down by.
64
+ # @param run_unit [TrophyApiClient::CreateLeaderboardRequestItemRunUnit] How often the leaderboard repeats. Omit for a non-recurring leaderboard. Streak
65
+ # leaderboards cannot repeat.
66
+ # @param run_interval [Integer] The number of `runUnit`s between repeats. Required when `runUnit` is set.
67
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
68
+ # @return [TrophyApiClient::CreateLeaderboardRequestItem]
69
+ def initialize(name:, key:, rank_by:, description: OMIT, status: OMIT, metric_id: OMIT, points_system_id: OMIT,
70
+ max_participants: OMIT, start: OMIT, end_: OMIT, breakdown_attributes: OMIT, run_unit: OMIT, run_interval: OMIT, additional_properties: nil)
71
+ @name = name
72
+ @key = key
73
+ @description = description if description != OMIT
74
+ @status = status if status != OMIT
75
+ @rank_by = rank_by
76
+ @metric_id = metric_id if metric_id != OMIT
77
+ @points_system_id = points_system_id if points_system_id != OMIT
78
+ @max_participants = max_participants if max_participants != OMIT
79
+ @start = start if start != OMIT
80
+ @end_ = end_ if end_ != OMIT
81
+ @breakdown_attributes = breakdown_attributes if breakdown_attributes != OMIT
82
+ @run_unit = run_unit if run_unit != OMIT
83
+ @run_interval = run_interval if run_interval != OMIT
84
+ @additional_properties = additional_properties
85
+ @_field_set = {
86
+ "name": name,
87
+ "key": key,
88
+ "description": description,
89
+ "status": status,
90
+ "rankBy": rank_by,
91
+ "metricId": metric_id,
92
+ "pointsSystemId": points_system_id,
93
+ "maxParticipants": max_participants,
94
+ "start": start,
95
+ "end": end_,
96
+ "breakdownAttributes": breakdown_attributes,
97
+ "runUnit": run_unit,
98
+ "runInterval": run_interval
99
+ }.reject do |_k, v|
100
+ v == OMIT
101
+ end
102
+ end
103
+
104
+ # Deserialize a JSON object to an instance of CreateLeaderboardRequestItem
105
+ #
106
+ # @param json_object [String]
107
+ # @return [TrophyApiClient::CreateLeaderboardRequestItem]
108
+ def self.from_json(json_object:)
109
+ struct = JSON.parse(json_object, object_class: OpenStruct)
110
+ parsed_json = JSON.parse(json_object)
111
+ name = parsed_json["name"]
112
+ key = parsed_json["key"]
113
+ description = parsed_json["description"]
114
+ status = parsed_json["status"]
115
+ rank_by = parsed_json["rankBy"]
116
+ metric_id = parsed_json["metricId"]
117
+ points_system_id = parsed_json["pointsSystemId"]
118
+ max_participants = parsed_json["maxParticipants"]
119
+ start = parsed_json["start"]
120
+ end_ = parsed_json["end"]
121
+ breakdown_attributes = parsed_json["breakdownAttributes"]
122
+ run_unit = parsed_json["runUnit"]
123
+ run_interval = parsed_json["runInterval"]
124
+ new(
125
+ name: name,
126
+ key: key,
127
+ description: description,
128
+ status: status,
129
+ rank_by: rank_by,
130
+ metric_id: metric_id,
131
+ points_system_id: points_system_id,
132
+ max_participants: max_participants,
133
+ start: start,
134
+ end_: end_,
135
+ breakdown_attributes: breakdown_attributes,
136
+ run_unit: run_unit,
137
+ run_interval: run_interval,
138
+ additional_properties: struct
139
+ )
140
+ end
141
+
142
+ # Serialize an instance of CreateLeaderboardRequestItem to a JSON object
143
+ #
144
+ # @return [String]
145
+ def to_json(*_args)
146
+ @_field_set&.to_json
147
+ end
148
+
149
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
150
+ # hash and check each fields type against the current object's property
151
+ # definitions.
152
+ #
153
+ # @param obj [Object]
154
+ # @return [Void]
155
+ def self.validate_raw(obj:)
156
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
157
+ obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
158
+ obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
159
+ obj.status&.is_a?(TrophyApiClient::CreateLeaderboardRequestItemStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
160
+ obj.rank_by.is_a?(TrophyApiClient::CreateLeaderboardRequestItemRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
161
+ obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
162
+ obj.points_system_id&.is_a?(String) != false || raise("Passed value for field obj.points_system_id is not the expected type, validation failed.")
163
+ obj.max_participants&.is_a?(Integer) != false || raise("Passed value for field obj.max_participants is not the expected type, validation failed.")
164
+ obj.start&.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
165
+ obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
166
+ obj.breakdown_attributes&.is_a?(Array) != false || raise("Passed value for field obj.breakdown_attributes is not the expected type, validation failed.")
167
+ obj.run_unit&.is_a?(TrophyApiClient::CreateLeaderboardRequestItemRunUnit) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.")
168
+ obj.run_interval&.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.")
169
+ end
170
+ end
171
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrophyApiClient
4
+ # What the leaderboard ranks by.
5
+ class CreateLeaderboardRequestItemRankBy
6
+ METRIC = "metric"
7
+ STREAK = "streak"
8
+ POINTS = "points"
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrophyApiClient
4
+ # How often the leaderboard repeats. Omit for a non-recurring leaderboard. Streak
5
+ # leaderboards cannot repeat.
6
+ class CreateLeaderboardRequestItemRunUnit
7
+ DAY = "day"
8
+ MONTH = "month"
9
+ YEAR = "year"
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrophyApiClient
4
+ # The initial user-facing status. Defaults to `inactive`. Use `scheduled` for
5
+ # leaderboards that should be active in the future and `finished` only when
6
+ # creating a leaderboard with an end date in the past.
7
+ class CreateLeaderboardRequestItemStatus
8
+ INACTIVE = "inactive"
9
+ ACTIVE = "active"
10
+ SCHEDULED = "scheduled"
11
+ FINISHED = "finished"
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "create_leaderboard_request_item"
4
+
5
+ module TrophyApiClient
6
+ CREATE_LEADERBOARDS_REQUEST = Array
7
+ end
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "admin_leaderboard"
4
+ require_relative "admin_issue"
5
+ require "ostruct"
6
+ require "json"
7
+
8
+ module TrophyApiClient
9
+ # Response containing created leaderboards and any per-item issues.
10
+ class CreateLeaderboardsResponse
11
+ # @return [Array<TrophyApiClient::AdminLeaderboard>] Array of successfully created leaderboards.
12
+ attr_reader :created
13
+ # @return [Array<TrophyApiClient::AdminIssue>] Array of issues encountered during leaderboard creation.
14
+ attr_reader :issues
15
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
16
+ attr_reader :additional_properties
17
+ # @return [Object]
18
+ attr_reader :_field_set
19
+ protected :_field_set
20
+
21
+ OMIT = Object.new
22
+
23
+ # @param created [Array<TrophyApiClient::AdminLeaderboard>] Array of successfully created leaderboards.
24
+ # @param issues [Array<TrophyApiClient::AdminIssue>] Array of issues encountered during leaderboard creation.
25
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
26
+ # @return [TrophyApiClient::CreateLeaderboardsResponse]
27
+ def initialize(created:, issues:, additional_properties: nil)
28
+ @created = created
29
+ @issues = issues
30
+ @additional_properties = additional_properties
31
+ @_field_set = { "created": created, "issues": issues }
32
+ end
33
+
34
+ # Deserialize a JSON object to an instance of CreateLeaderboardsResponse
35
+ #
36
+ # @param json_object [String]
37
+ # @return [TrophyApiClient::CreateLeaderboardsResponse]
38
+ def self.from_json(json_object:)
39
+ struct = JSON.parse(json_object, object_class: OpenStruct)
40
+ parsed_json = JSON.parse(json_object)
41
+ created = parsed_json["created"]&.map do |item|
42
+ item = item.to_json
43
+ TrophyApiClient::AdminLeaderboard.from_json(json_object: item)
44
+ end
45
+ issues = parsed_json["issues"]&.map do |item|
46
+ item = item.to_json
47
+ TrophyApiClient::AdminIssue.from_json(json_object: item)
48
+ end
49
+ new(
50
+ created: created,
51
+ issues: issues,
52
+ additional_properties: struct
53
+ )
54
+ end
55
+
56
+ # Serialize an instance of CreateLeaderboardsResponse to a JSON object
57
+ #
58
+ # @return [String]
59
+ def to_json(*_args)
60
+ @_field_set&.to_json
61
+ end
62
+
63
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
64
+ # hash and check each fields type against the current object's property
65
+ # definitions.
66
+ #
67
+ # @param obj [Object]
68
+ # @return [Void]
69
+ def self.validate_raw(obj:)
70
+ obj.created.is_a?(Array) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
71
+ obj.issues.is_a?(Array) != false || raise("Passed value for field obj.issues is not the expected type, validation failed.")
72
+ end
73
+ end
74
+ end