trophy_api_client 1.7.0 → 1.9.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.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gemconfig.rb +1 -1
  3. data/lib/requests.rb +34 -8
  4. data/lib/trophy_api_client/achievements/client.rb +4 -0
  5. data/lib/trophy_api_client/admin/attributes/client.rb +10 -0
  6. data/lib/trophy_api_client/admin/client.rb +7 -0
  7. data/lib/trophy_api_client/admin/leaderboards/client.rb +10 -0
  8. data/lib/trophy_api_client/admin/metrics/client.rb +10 -0
  9. data/lib/trophy_api_client/admin/points/boosts/client.rb +268 -39
  10. data/lib/trophy_api_client/admin/points/client.rb +21 -0
  11. data/lib/trophy_api_client/admin/points/levels/client.rb +412 -0
  12. data/lib/trophy_api_client/admin/points/systems/client.rb +384 -0
  13. data/lib/trophy_api_client/admin/points/triggers/client.rb +412 -0
  14. data/lib/trophy_api_client/admin/streaks/client.rb +2 -0
  15. data/lib/trophy_api_client/admin/streaks/freezes/client.rb +2 -0
  16. data/lib/trophy_api_client/admin/tenants/client.rb +376 -0
  17. data/lib/trophy_api_client/leaderboards/client.rb +4 -0
  18. data/lib/trophy_api_client/metrics/client.rb +2 -0
  19. data/lib/trophy_api_client/points/client.rb +10 -0
  20. data/lib/trophy_api_client/streaks/client.rb +4 -0
  21. data/lib/trophy_api_client/types/{created_points_boost.rb → admin_points_boost.rb} +39 -23
  22. data/lib/trophy_api_client/types/{created_points_boost_rounding.rb → admin_points_boost_rounding.rb} +1 -1
  23. data/lib/trophy_api_client/types/{created_points_boost_status.rb → admin_points_boost_status.rb} +1 -1
  24. data/lib/trophy_api_client/types/admin_points_boost_user_attributes_item.rb +65 -0
  25. data/lib/trophy_api_client/types/admin_points_level.rb +109 -0
  26. data/lib/trophy_api_client/types/admin_points_level_badge.rb +55 -0
  27. data/lib/trophy_api_client/types/admin_points_system.rb +118 -0
  28. data/lib/trophy_api_client/types/admin_points_system_badge.rb +55 -0
  29. data/lib/trophy_api_client/types/admin_points_system_status.rb +9 -0
  30. data/lib/trophy_api_client/types/admin_points_trigger.rb +175 -0
  31. data/lib/trophy_api_client/types/admin_points_trigger_event_attributes_item.rb +66 -0
  32. data/lib/trophy_api_client/types/admin_points_trigger_status.rb +9 -0
  33. data/lib/trophy_api_client/types/admin_points_trigger_time_unit.rb +9 -0
  34. data/lib/trophy_api_client/types/admin_points_trigger_type.rb +12 -0
  35. data/lib/trophy_api_client/types/admin_points_trigger_user_attributes_item.rb +65 -0
  36. data/lib/trophy_api_client/types/admin_tenant.rb +103 -0
  37. data/lib/trophy_api_client/types/admin_tenant_status.rb +9 -0
  38. data/lib/trophy_api_client/types/create_points_boost_request_item.rb +125 -0
  39. data/lib/trophy_api_client/types/create_points_boost_request_item_rounding.rb +10 -0
  40. data/lib/trophy_api_client/types/create_points_boost_request_item_user_attributes_item.rb +67 -0
  41. data/lib/trophy_api_client/types/create_points_boosts_request.rb +7 -0
  42. data/lib/trophy_api_client/types/create_points_boosts_response.rb +4 -4
  43. data/lib/trophy_api_client/types/create_points_level_request_item.rb +103 -0
  44. data/lib/trophy_api_client/types/create_points_level_request_item_badge.rb +56 -0
  45. data/lib/trophy_api_client/types/create_points_levels_request.rb +7 -0
  46. data/lib/trophy_api_client/types/create_points_levels_response.rb +74 -0
  47. data/lib/trophy_api_client/types/create_points_system_request_item.rb +140 -0
  48. data/lib/trophy_api_client/types/create_points_system_request_item_badge.rb +55 -0
  49. data/lib/trophy_api_client/types/create_points_systems_request.rb +7 -0
  50. data/lib/trophy_api_client/types/create_points_systems_response.rb +74 -0
  51. data/lib/trophy_api_client/types/create_points_trigger_request_item.rb +167 -0
  52. data/lib/trophy_api_client/types/create_points_trigger_request_item_event_attributes_item.rb +67 -0
  53. data/lib/trophy_api_client/types/create_points_trigger_request_item_status.rb +9 -0
  54. data/lib/trophy_api_client/types/create_points_trigger_request_item_time_unit.rb +9 -0
  55. data/lib/trophy_api_client/types/create_points_trigger_request_item_type.rb +12 -0
  56. data/lib/trophy_api_client/types/create_points_trigger_request_item_user_attributes_item.rb +67 -0
  57. data/lib/trophy_api_client/types/create_points_triggers_request.rb +7 -0
  58. data/lib/trophy_api_client/types/create_points_triggers_response.rb +74 -0
  59. data/lib/trophy_api_client/types/create_tenant_request_item.rb +66 -0
  60. data/lib/trophy_api_client/types/create_tenants_request.rb +7 -0
  61. data/lib/trophy_api_client/types/create_tenants_response.rb +74 -0
  62. data/lib/trophy_api_client/types/created_admin_points_system.rb +163 -0
  63. data/lib/trophy_api_client/types/delete_points_levels_response.rb +74 -0
  64. data/lib/trophy_api_client/types/delete_points_systems_response.rb +74 -0
  65. data/lib/trophy_api_client/types/delete_points_triggers_response.rb +75 -0
  66. data/lib/trophy_api_client/types/delete_tenants_response.rb +74 -0
  67. data/lib/trophy_api_client/types/list_points_boosts_response.rb +7 -0
  68. data/lib/trophy_api_client/types/list_points_levels_response.rb +7 -0
  69. data/lib/trophy_api_client/types/list_points_systems_response.rb +7 -0
  70. data/lib/trophy_api_client/types/list_points_triggers_response.rb +7 -0
  71. data/lib/trophy_api_client/types/list_tenants_response.rb +7 -0
  72. data/lib/trophy_api_client/types/patch_points_boosts_request.rb +7 -0
  73. data/lib/trophy_api_client/types/patch_points_boosts_request_item.rb +118 -0
  74. data/lib/trophy_api_client/types/patch_points_boosts_request_item_rounding.rb +10 -0
  75. data/lib/trophy_api_client/types/patch_points_boosts_request_item_user_attributes_item.rb +67 -0
  76. data/lib/trophy_api_client/types/patch_points_boosts_response.rb +74 -0
  77. data/lib/trophy_api_client/types/patch_points_levels_request.rb +7 -0
  78. data/lib/trophy_api_client/types/patch_points_levels_request_item.rb +100 -0
  79. data/lib/trophy_api_client/types/patch_points_levels_request_item_badge.rb +55 -0
  80. data/lib/trophy_api_client/types/patch_points_levels_response.rb +74 -0
  81. data/lib/trophy_api_client/types/patch_points_triggers_request.rb +7 -0
  82. data/lib/trophy_api_client/types/patch_points_triggers_request_item.rb +174 -0
  83. data/lib/trophy_api_client/types/patch_points_triggers_request_item_event_attributes_item.rb +67 -0
  84. data/lib/trophy_api_client/types/patch_points_triggers_request_item_status.rb +9 -0
  85. data/lib/trophy_api_client/types/patch_points_triggers_request_item_time_unit.rb +9 -0
  86. data/lib/trophy_api_client/types/patch_points_triggers_request_item_type.rb +13 -0
  87. data/lib/trophy_api_client/types/patch_points_triggers_request_item_user_attributes_item.rb +67 -0
  88. data/lib/trophy_api_client/types/patch_points_triggers_response.rb +74 -0
  89. data/lib/trophy_api_client/types/update_points_system_request_item.rb +102 -0
  90. data/lib/trophy_api_client/types/update_points_system_request_item_badge.rb +55 -0
  91. data/lib/trophy_api_client/types/update_points_systems_request.rb +7 -0
  92. data/lib/trophy_api_client/types/update_points_systems_response.rb +74 -0
  93. data/lib/trophy_api_client/types/update_tenant_request_item.rb +75 -0
  94. data/lib/trophy_api_client/types/update_tenants_request.rb +7 -0
  95. data/lib/trophy_api_client/types/update_tenants_response.rb +74 -0
  96. data/lib/trophy_api_client/users/client.rb +32 -0
  97. data/lib/trophy_api_client/version.rb +1 -1
  98. data/lib/trophy_api_client.rb +12 -4
  99. data/lib/types_export.rb +74 -5
  100. metadata +80 -7
  101. data/lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item.rb +0 -111
  102. data/lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item_rounding.rb +0 -16
@@ -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,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "admin_tenant_status"
4
+ require "date"
5
+ require "ostruct"
6
+ require "json"
7
+
8
+ module TrophyApiClient
9
+ # A tenant in a multi-tenant environment.
10
+ class AdminTenant
11
+ # @return [String] The tenant UUID.
12
+ attr_reader :id
13
+ # @return [String] The external customer ID for this tenant.
14
+ attr_reader :customer_id
15
+ # @return [String] Human-readable name for the tenant.
16
+ attr_reader :name
17
+ # @return [TrophyApiClient::AdminTenantStatus] The lifecycle status of the tenant.
18
+ attr_reader :status
19
+ # @return [DateTime] When the tenant was created.
20
+ attr_reader :created
21
+ # @return [DateTime] When the tenant was last updated.
22
+ attr_reader :updated
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 id [String] The tenant UUID.
32
+ # @param customer_id [String] The external customer ID for this tenant.
33
+ # @param name [String] Human-readable name for the tenant.
34
+ # @param status [TrophyApiClient::AdminTenantStatus] The lifecycle status of the tenant.
35
+ # @param created [DateTime] When the tenant was created.
36
+ # @param updated [DateTime] When the tenant was last updated.
37
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
38
+ # @return [TrophyApiClient::AdminTenant]
39
+ def initialize(id:, customer_id:, name:, status:, created:, updated:, additional_properties: nil)
40
+ @id = id
41
+ @customer_id = customer_id
42
+ @name = name
43
+ @status = status
44
+ @created = created
45
+ @updated = updated
46
+ @additional_properties = additional_properties
47
+ @_field_set = {
48
+ "id": id,
49
+ "customerId": customer_id,
50
+ "name": name,
51
+ "status": status,
52
+ "created": created,
53
+ "updated": updated
54
+ }
55
+ end
56
+
57
+ # Deserialize a JSON object to an instance of AdminTenant
58
+ #
59
+ # @param json_object [String]
60
+ # @return [TrophyApiClient::AdminTenant]
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
+ customer_id = parsed_json["customerId"]
66
+ name = parsed_json["name"]
67
+ status = parsed_json["status"]
68
+ created = (DateTime.parse(parsed_json["created"]) unless parsed_json["created"].nil?)
69
+ updated = (DateTime.parse(parsed_json["updated"]) unless parsed_json["updated"].nil?)
70
+ new(
71
+ id: id,
72
+ customer_id: customer_id,
73
+ name: name,
74
+ status: status,
75
+ created: created,
76
+ updated: updated,
77
+ additional_properties: struct
78
+ )
79
+ end
80
+
81
+ # Serialize an instance of AdminTenant 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.customer_id.is_a?(String) != false || raise("Passed value for field obj.customer_id 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.status.is_a?(TrophyApiClient::AdminTenantStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
99
+ obj.created.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
100
+ obj.updated.is_a?(DateTime) != false || raise("Passed value for field obj.updated is not the expected type, validation failed.")
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrophyApiClient
4
+ # The lifecycle status of the tenant.
5
+ class AdminTenantStatus
6
+ ACTIVE = "active"
7
+ ARCHIVED = "archived"
8
+ end
9
+ end
@@ -0,0 +1,125 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "create_points_boost_request_item_rounding"
4
+ require_relative "create_points_boost_request_item_user_attributes_item"
5
+ require "ostruct"
6
+ require "json"
7
+
8
+ module TrophyApiClient
9
+ # A points boost to create. May optionally target a specific user via `userId` or
10
+ # filter by user attributes via `userAttributes`. These two fields are mutually
11
+ # exclusive.
12
+ class CreatePointsBoostRequestItem
13
+ # @return [String] The ID of the user to create a boost for. Mutually exclusive with
14
+ # `userAttributes` — providing `userAttributes` when `userId` is set will result
15
+ # in an error. Omit for a global boost.
16
+ attr_reader :user_id
17
+ # @return [String] The name of the boost.
18
+ attr_reader :name
19
+ # @return [String] The start date of the boost (YYYY-MM-DD).
20
+ attr_reader :start
21
+ # @return [String] The end date of the boost (YYYY-MM-DD). If null, the boost has no end date.
22
+ attr_reader :end_
23
+ # @return [Float] The points multiplier. Must be greater than 0, not equal to 1, and less than
24
+ # 100.
25
+ attr_reader :multiplier
26
+ # @return [TrophyApiClient::CreatePointsBoostRequestItemRounding] How to round the boosted points. Defaults to 'down'.
27
+ attr_reader :rounding
28
+ # @return [Array<TrophyApiClient::CreatePointsBoostRequestItemUserAttributesItem>] User attribute filters for the boost. Cannot be provided when `userId` is set.
29
+ attr_reader :user_attributes
30
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
31
+ attr_reader :additional_properties
32
+ # @return [Object]
33
+ attr_reader :_field_set
34
+ protected :_field_set
35
+
36
+ OMIT = Object.new
37
+
38
+ # @param user_id [String] The ID of the user to create a boost for. Mutually exclusive with
39
+ # `userAttributes` — providing `userAttributes` when `userId` is set will result
40
+ # in an error. Omit for a global boost.
41
+ # @param name [String] The name of the boost.
42
+ # @param start [String] The start date of the boost (YYYY-MM-DD).
43
+ # @param end_ [String] The end date of the boost (YYYY-MM-DD). If null, the boost has no end date.
44
+ # @param multiplier [Float] The points multiplier. Must be greater than 0, not equal to 1, and less than
45
+ # 100.
46
+ # @param rounding [TrophyApiClient::CreatePointsBoostRequestItemRounding] How to round the boosted points. Defaults to 'down'.
47
+ # @param user_attributes [Array<TrophyApiClient::CreatePointsBoostRequestItemUserAttributesItem>] User attribute filters for the boost. Cannot be provided when `userId` is set.
48
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
49
+ # @return [TrophyApiClient::CreatePointsBoostRequestItem]
50
+ def initialize(name:, start:, multiplier:, user_id: OMIT, end_: OMIT, rounding: OMIT, user_attributes: OMIT,
51
+ additional_properties: nil)
52
+ @user_id = user_id if user_id != OMIT
53
+ @name = name
54
+ @start = start
55
+ @end_ = end_ if end_ != OMIT
56
+ @multiplier = multiplier
57
+ @rounding = rounding if rounding != OMIT
58
+ @user_attributes = user_attributes if user_attributes != OMIT
59
+ @additional_properties = additional_properties
60
+ @_field_set = {
61
+ "userId": user_id,
62
+ "name": name,
63
+ "start": start,
64
+ "end": end_,
65
+ "multiplier": multiplier,
66
+ "rounding": rounding,
67
+ "userAttributes": user_attributes
68
+ }.reject do |_k, v|
69
+ v == OMIT
70
+ end
71
+ end
72
+
73
+ # Deserialize a JSON object to an instance of CreatePointsBoostRequestItem
74
+ #
75
+ # @param json_object [String]
76
+ # @return [TrophyApiClient::CreatePointsBoostRequestItem]
77
+ def self.from_json(json_object:)
78
+ struct = JSON.parse(json_object, object_class: OpenStruct)
79
+ parsed_json = JSON.parse(json_object)
80
+ user_id = parsed_json["userId"]
81
+ name = parsed_json["name"]
82
+ start = parsed_json["start"]
83
+ end_ = parsed_json["end"]
84
+ multiplier = parsed_json["multiplier"]
85
+ rounding = parsed_json["rounding"]
86
+ user_attributes = parsed_json["userAttributes"]&.map do |item|
87
+ item = item.to_json
88
+ TrophyApiClient::CreatePointsBoostRequestItemUserAttributesItem.from_json(json_object: item)
89
+ end
90
+ new(
91
+ user_id: user_id,
92
+ name: name,
93
+ start: start,
94
+ end_: end_,
95
+ multiplier: multiplier,
96
+ rounding: rounding,
97
+ user_attributes: user_attributes,
98
+ additional_properties: struct
99
+ )
100
+ end
101
+
102
+ # Serialize an instance of CreatePointsBoostRequestItem to a JSON object
103
+ #
104
+ # @return [String]
105
+ def to_json(*_args)
106
+ @_field_set&.to_json
107
+ end
108
+
109
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
110
+ # hash and check each fields type against the current object's property
111
+ # definitions.
112
+ #
113
+ # @param obj [Object]
114
+ # @return [Void]
115
+ def self.validate_raw(obj:)
116
+ obj.user_id&.is_a?(String) != false || raise("Passed value for field obj.user_id is not the expected type, validation failed.")
117
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
118
+ obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
119
+ obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
120
+ obj.multiplier.is_a?(Float) != false || raise("Passed value for field obj.multiplier is not the expected type, validation failed.")
121
+ obj.rounding&.is_a?(TrophyApiClient::CreatePointsBoostRequestItemRounding) != false || raise("Passed value for field obj.rounding is not the expected type, validation failed.")
122
+ obj.user_attributes&.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.")
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrophyApiClient
4
+ # How to round the boosted points. Defaults to 'down'.
5
+ class CreatePointsBoostRequestItemRounding
6
+ DOWN = "down"
7
+ UP = "up"
8
+ NEAREST = "nearest"
9
+ end
10
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module TrophyApiClient
7
+ class CreatePointsBoostRequestItemUserAttributesItem
8
+ # @return [String] The UUID of the user attribute.
9
+ attr_reader :attribute_id
10
+ # @return [String] The value to match.
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] The UUID of the user attribute.
21
+ # @param attribute_value [String] The value to match.
22
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
23
+ # @return [TrophyApiClient::CreatePointsBoostRequestItemUserAttributesItem]
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
+ # CreatePointsBoostRequestItemUserAttributesItem
33
+ #
34
+ # @param json_object [String]
35
+ # @return [TrophyApiClient::CreatePointsBoostRequestItemUserAttributesItem]
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 CreatePointsBoostRequestItemUserAttributesItem to a
49
+ # JSON object
50
+ #
51
+ # @return [String]
52
+ def to_json(*_args)
53
+ @_field_set&.to_json
54
+ end
55
+
56
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
57
+ # hash and check each fields type against the current object's property
58
+ # definitions.
59
+ #
60
+ # @param obj [Object]
61
+ # @return [Void]
62
+ def self.validate_raw(obj:)
63
+ obj.attribute_id.is_a?(String) != false || raise("Passed value for field obj.attribute_id is not the expected type, validation failed.")
64
+ obj.attribute_value.is_a?(String) != false || raise("Passed value for field obj.attribute_value is not the expected type, validation failed.")
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "create_points_boost_request_item"
4
+
5
+ module TrophyApiClient
6
+ CREATE_POINTS_BOOSTS_REQUEST = Array
7
+ end