trophy_api_client 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gemconfig.rb +1 -1
- data/lib/trophy_api_client/achievements/client.rb +79 -7
- data/lib/trophy_api_client/points/client.rb +175 -0
- data/lib/trophy_api_client/types/achievement_completion_response.rb +5 -5
- data/lib/trophy_api_client/types/achievement_response.rb +29 -15
- data/lib/trophy_api_client/types/achievement_response_trigger.rb +10 -0
- data/lib/trophy_api_client/types/achievement_with_stats_response.rb +176 -0
- data/lib/trophy_api_client/types/completed_achievement_response.rb +169 -0
- data/lib/trophy_api_client/types/event_response.rb +28 -11
- data/lib/trophy_api_client/types/get_user_points_response.rb +71 -0
- data/lib/trophy_api_client/types/metric_event_points_response.rb +78 -0
- data/lib/trophy_api_client/types/{increment_metric_streak_response.rb → metric_event_streak_response.rb} +6 -6
- data/lib/trophy_api_client/types/metric_response.rb +4 -4
- data/lib/trophy_api_client/types/points_award.rb +80 -0
- data/lib/trophy_api_client/types/points_range.rb +74 -0
- data/lib/trophy_api_client/types/points_summary_response.rb +7 -0
- data/lib/trophy_api_client/types/points_trigger.rb +116 -0
- data/lib/trophy_api_client/types/points_trigger_response.rb +164 -0
- data/lib/trophy_api_client/types/points_trigger_response_status.rb +9 -0
- data/lib/trophy_api_client/types/points_trigger_response_type.rb +10 -0
- data/lib/trophy_api_client/types/points_trigger_type.rb +10 -0
- data/lib/trophy_api_client/users/client.rb +278 -5
- data/lib/trophy_api_client/users/types/users_metric_event_summary_request_aggregation.rb +11 -0
- data/lib/trophy_api_client/users/types/users_metric_event_summary_response_item.rb +76 -0
- data/lib/trophy_api_client/users/types/users_points_event_summary_request_aggregation.rb +11 -0
- data/lib/trophy_api_client/users/types/users_points_event_summary_response_item.rb +76 -0
- data/lib/trophy_api_client/version.rb +1 -1
- data/lib/trophy_api_client.rb +7 -0
- data/lib/types_export.rb +18 -1
- metadata +20 -2
@@ -0,0 +1,176 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "achievement_response_trigger"
|
4
|
+
require_relative "metric_event_streak_response"
|
5
|
+
require "ostruct"
|
6
|
+
require "json"
|
7
|
+
|
8
|
+
module TrophyApiClient
|
9
|
+
class AchievementWithStatsResponse
|
10
|
+
# @return [Integer] The number of users who have completed this achievement.
|
11
|
+
attr_reader :completions
|
12
|
+
# @return [Float] The percentage of all users who have completed this achievement.
|
13
|
+
attr_reader :completed_percentage
|
14
|
+
# @return [String] The unique ID of the achievement.
|
15
|
+
attr_reader :id
|
16
|
+
# @return [String] The name of this achievement.
|
17
|
+
attr_reader :name
|
18
|
+
# @return [TrophyApiClient::AchievementResponseTrigger] The trigger of the achievement.
|
19
|
+
attr_reader :trigger
|
20
|
+
# @return [String] The description of this achievement.
|
21
|
+
attr_reader :description
|
22
|
+
# @return [String] The URL of the badge image for the achievement, if one has been uploaded.
|
23
|
+
attr_reader :badge_url
|
24
|
+
# @return [String] The key used to reference this achievement in the API (only applicable if
|
25
|
+
# trigger = 'api')
|
26
|
+
attr_reader :key
|
27
|
+
# @return [Integer] The length of the streak required to complete the achievement (only applicable
|
28
|
+
# if trigger = 'streak')
|
29
|
+
attr_reader :streak_length
|
30
|
+
# @return [String] The ID of the metric associated with this achievement (only applicable if
|
31
|
+
# trigger = 'metric')
|
32
|
+
attr_reader :metric_id
|
33
|
+
# @return [Float] The value of the metric required to complete the achievement (only applicable if
|
34
|
+
# trigger = 'metric')
|
35
|
+
attr_reader :metric_value
|
36
|
+
# @return [String] The name of the metric associated with this achievement (only applicable if
|
37
|
+
# trigger = 'metric')
|
38
|
+
attr_reader :metric_name
|
39
|
+
# @return [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
40
|
+
attr_reader :current_streak
|
41
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
42
|
+
attr_reader :additional_properties
|
43
|
+
# @return [Object]
|
44
|
+
attr_reader :_field_set
|
45
|
+
protected :_field_set
|
46
|
+
|
47
|
+
OMIT = Object.new
|
48
|
+
|
49
|
+
# @param completions [Integer] The number of users who have completed this achievement.
|
50
|
+
# @param completed_percentage [Float] The percentage of all users who have completed this achievement.
|
51
|
+
# @param id [String] The unique ID of the achievement.
|
52
|
+
# @param name [String] The name of this achievement.
|
53
|
+
# @param trigger [TrophyApiClient::AchievementResponseTrigger] The trigger of the achievement.
|
54
|
+
# @param description [String] The description of this achievement.
|
55
|
+
# @param badge_url [String] The URL of the badge image for the achievement, if one has been uploaded.
|
56
|
+
# @param key [String] The key used to reference this achievement in the API (only applicable if
|
57
|
+
# trigger = 'api')
|
58
|
+
# @param streak_length [Integer] The length of the streak required to complete the achievement (only applicable
|
59
|
+
# if trigger = 'streak')
|
60
|
+
# @param metric_id [String] The ID of the metric associated with this achievement (only applicable if
|
61
|
+
# trigger = 'metric')
|
62
|
+
# @param metric_value [Float] The value of the metric required to complete the achievement (only applicable if
|
63
|
+
# trigger = 'metric')
|
64
|
+
# @param metric_name [String] The name of the metric associated with this achievement (only applicable if
|
65
|
+
# trigger = 'metric')
|
66
|
+
# @param current_streak [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
67
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
68
|
+
# @return [TrophyApiClient::AchievementWithStatsResponse]
|
69
|
+
def initialize(id:, name:, trigger:, completions: OMIT, completed_percentage: OMIT, description: OMIT,
|
70
|
+
badge_url: OMIT, key: OMIT, streak_length: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, current_streak: OMIT, additional_properties: nil)
|
71
|
+
@completions = completions if completions != OMIT
|
72
|
+
@completed_percentage = completed_percentage if completed_percentage != OMIT
|
73
|
+
@id = id
|
74
|
+
@name = name
|
75
|
+
@trigger = trigger
|
76
|
+
@description = description if description != OMIT
|
77
|
+
@badge_url = badge_url if badge_url != OMIT
|
78
|
+
@key = key if key != OMIT
|
79
|
+
@streak_length = streak_length if streak_length != OMIT
|
80
|
+
@metric_id = metric_id if metric_id != OMIT
|
81
|
+
@metric_value = metric_value if metric_value != OMIT
|
82
|
+
@metric_name = metric_name if metric_name != OMIT
|
83
|
+
@current_streak = current_streak if current_streak != OMIT
|
84
|
+
@additional_properties = additional_properties
|
85
|
+
@_field_set = {
|
86
|
+
"completions": completions,
|
87
|
+
"completedPercentage": completed_percentage,
|
88
|
+
"id": id,
|
89
|
+
"name": name,
|
90
|
+
"trigger": trigger,
|
91
|
+
"description": description,
|
92
|
+
"badgeUrl": badge_url,
|
93
|
+
"key": key,
|
94
|
+
"streakLength": streak_length,
|
95
|
+
"metricId": metric_id,
|
96
|
+
"metricValue": metric_value,
|
97
|
+
"metricName": metric_name,
|
98
|
+
"currentStreak": current_streak
|
99
|
+
}.reject do |_k, v|
|
100
|
+
v == OMIT
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# Deserialize a JSON object to an instance of AchievementWithStatsResponse
|
105
|
+
#
|
106
|
+
# @param json_object [String]
|
107
|
+
# @return [TrophyApiClient::AchievementWithStatsResponse]
|
108
|
+
def self.from_json(json_object:)
|
109
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
110
|
+
parsed_json = JSON.parse(json_object)
|
111
|
+
completions = parsed_json["completions"]
|
112
|
+
completed_percentage = parsed_json["completedPercentage"]
|
113
|
+
id = parsed_json["id"]
|
114
|
+
name = parsed_json["name"]
|
115
|
+
trigger = parsed_json["trigger"]
|
116
|
+
description = parsed_json["description"]
|
117
|
+
badge_url = parsed_json["badgeUrl"]
|
118
|
+
key = parsed_json["key"]
|
119
|
+
streak_length = parsed_json["streakLength"]
|
120
|
+
metric_id = parsed_json["metricId"]
|
121
|
+
metric_value = parsed_json["metricValue"]
|
122
|
+
metric_name = parsed_json["metricName"]
|
123
|
+
if parsed_json["currentStreak"].nil?
|
124
|
+
current_streak = nil
|
125
|
+
else
|
126
|
+
current_streak = parsed_json["currentStreak"].to_json
|
127
|
+
current_streak = TrophyApiClient::MetricEventStreakResponse.from_json(json_object: current_streak)
|
128
|
+
end
|
129
|
+
new(
|
130
|
+
completions: completions,
|
131
|
+
completed_percentage: completed_percentage,
|
132
|
+
id: id,
|
133
|
+
name: name,
|
134
|
+
trigger: trigger,
|
135
|
+
description: description,
|
136
|
+
badge_url: badge_url,
|
137
|
+
key: key,
|
138
|
+
streak_length: streak_length,
|
139
|
+
metric_id: metric_id,
|
140
|
+
metric_value: metric_value,
|
141
|
+
metric_name: metric_name,
|
142
|
+
current_streak: current_streak,
|
143
|
+
additional_properties: struct
|
144
|
+
)
|
145
|
+
end
|
146
|
+
|
147
|
+
# Serialize an instance of AchievementWithStatsResponse to a JSON object
|
148
|
+
#
|
149
|
+
# @return [String]
|
150
|
+
def to_json(*_args)
|
151
|
+
@_field_set&.to_json
|
152
|
+
end
|
153
|
+
|
154
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
155
|
+
# hash and check each fields type against the current object's property
|
156
|
+
# definitions.
|
157
|
+
#
|
158
|
+
# @param obj [Object]
|
159
|
+
# @return [Void]
|
160
|
+
def self.validate_raw(obj:)
|
161
|
+
obj.completions&.is_a?(Integer) != false || raise("Passed value for field obj.completions is not the expected type, validation failed.")
|
162
|
+
obj.completed_percentage&.is_a?(Float) != false || raise("Passed value for field obj.completed_percentage is not the expected type, validation failed.")
|
163
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
164
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
165
|
+
obj.trigger.is_a?(TrophyApiClient::AchievementResponseTrigger) != false || raise("Passed value for field obj.trigger is not the expected type, validation failed.")
|
166
|
+
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
167
|
+
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
168
|
+
obj.key&.is_a?(String) != false || raise("Passed value for field obj.key 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.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
|
171
|
+
obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
|
172
|
+
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
173
|
+
obj.current_streak.nil? || TrophyApiClient::MetricEventStreakResponse.validate_raw(obj: obj.current_streak)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "date"
|
4
|
+
require_relative "achievement_response_trigger"
|
5
|
+
require_relative "metric_event_streak_response"
|
6
|
+
require "ostruct"
|
7
|
+
require "json"
|
8
|
+
|
9
|
+
module TrophyApiClient
|
10
|
+
class CompletedAchievementResponse
|
11
|
+
# @return [DateTime] The date and time the achievement was completed, in ISO 8601 format.
|
12
|
+
attr_reader :achieved_at
|
13
|
+
# @return [String] The unique ID of the achievement.
|
14
|
+
attr_reader :id
|
15
|
+
# @return [String] The name of this achievement.
|
16
|
+
attr_reader :name
|
17
|
+
# @return [TrophyApiClient::AchievementResponseTrigger] The trigger of the achievement.
|
18
|
+
attr_reader :trigger
|
19
|
+
# @return [String] The description of this achievement.
|
20
|
+
attr_reader :description
|
21
|
+
# @return [String] The URL of the badge image for the achievement, if one has been uploaded.
|
22
|
+
attr_reader :badge_url
|
23
|
+
# @return [String] The key used to reference this achievement in the API (only applicable if
|
24
|
+
# trigger = 'api')
|
25
|
+
attr_reader :key
|
26
|
+
# @return [Integer] The length of the streak required to complete the achievement (only applicable
|
27
|
+
# if trigger = 'streak')
|
28
|
+
attr_reader :streak_length
|
29
|
+
# @return [String] The ID of the metric associated with this achievement (only applicable if
|
30
|
+
# trigger = 'metric')
|
31
|
+
attr_reader :metric_id
|
32
|
+
# @return [Float] The value of the metric required to complete the achievement (only applicable if
|
33
|
+
# trigger = 'metric')
|
34
|
+
attr_reader :metric_value
|
35
|
+
# @return [String] The name of the metric associated with this achievement (only applicable if
|
36
|
+
# trigger = 'metric')
|
37
|
+
attr_reader :metric_name
|
38
|
+
# @return [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
39
|
+
attr_reader :current_streak
|
40
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
41
|
+
attr_reader :additional_properties
|
42
|
+
# @return [Object]
|
43
|
+
attr_reader :_field_set
|
44
|
+
protected :_field_set
|
45
|
+
|
46
|
+
OMIT = Object.new
|
47
|
+
|
48
|
+
# @param achieved_at [DateTime] The date and time the achievement was completed, in ISO 8601 format.
|
49
|
+
# @param id [String] The unique ID of the achievement.
|
50
|
+
# @param name [String] The name of this achievement.
|
51
|
+
# @param trigger [TrophyApiClient::AchievementResponseTrigger] The trigger of the achievement.
|
52
|
+
# @param description [String] The description of this achievement.
|
53
|
+
# @param badge_url [String] The URL of the badge image for the achievement, if one has been uploaded.
|
54
|
+
# @param key [String] The key used to reference this achievement in the API (only applicable if
|
55
|
+
# trigger = 'api')
|
56
|
+
# @param streak_length [Integer] The length of the streak required to complete the achievement (only applicable
|
57
|
+
# if trigger = 'streak')
|
58
|
+
# @param metric_id [String] The ID of the metric associated with this achievement (only applicable if
|
59
|
+
# trigger = 'metric')
|
60
|
+
# @param metric_value [Float] The value of the metric required to complete the achievement (only applicable if
|
61
|
+
# trigger = 'metric')
|
62
|
+
# @param metric_name [String] The name of the metric associated with this achievement (only applicable if
|
63
|
+
# trigger = 'metric')
|
64
|
+
# @param current_streak [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
65
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
66
|
+
# @return [TrophyApiClient::CompletedAchievementResponse]
|
67
|
+
def initialize(id:, name:, trigger:, achieved_at: OMIT, description: OMIT, badge_url: OMIT, key: OMIT,
|
68
|
+
streak_length: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, current_streak: OMIT, additional_properties: nil)
|
69
|
+
@achieved_at = achieved_at if achieved_at != OMIT
|
70
|
+
@id = id
|
71
|
+
@name = name
|
72
|
+
@trigger = trigger
|
73
|
+
@description = description if description != OMIT
|
74
|
+
@badge_url = badge_url if badge_url != OMIT
|
75
|
+
@key = key if key != OMIT
|
76
|
+
@streak_length = streak_length if streak_length != OMIT
|
77
|
+
@metric_id = metric_id if metric_id != OMIT
|
78
|
+
@metric_value = metric_value if metric_value != OMIT
|
79
|
+
@metric_name = metric_name if metric_name != OMIT
|
80
|
+
@current_streak = current_streak if current_streak != OMIT
|
81
|
+
@additional_properties = additional_properties
|
82
|
+
@_field_set = {
|
83
|
+
"achievedAt": achieved_at,
|
84
|
+
"id": id,
|
85
|
+
"name": name,
|
86
|
+
"trigger": trigger,
|
87
|
+
"description": description,
|
88
|
+
"badgeUrl": badge_url,
|
89
|
+
"key": key,
|
90
|
+
"streakLength": streak_length,
|
91
|
+
"metricId": metric_id,
|
92
|
+
"metricValue": metric_value,
|
93
|
+
"metricName": metric_name,
|
94
|
+
"currentStreak": current_streak
|
95
|
+
}.reject do |_k, v|
|
96
|
+
v == OMIT
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# Deserialize a JSON object to an instance of CompletedAchievementResponse
|
101
|
+
#
|
102
|
+
# @param json_object [String]
|
103
|
+
# @return [TrophyApiClient::CompletedAchievementResponse]
|
104
|
+
def self.from_json(json_object:)
|
105
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
106
|
+
parsed_json = JSON.parse(json_object)
|
107
|
+
achieved_at = (DateTime.parse(parsed_json["achievedAt"]) unless parsed_json["achievedAt"].nil?)
|
108
|
+
id = parsed_json["id"]
|
109
|
+
name = parsed_json["name"]
|
110
|
+
trigger = parsed_json["trigger"]
|
111
|
+
description = parsed_json["description"]
|
112
|
+
badge_url = parsed_json["badgeUrl"]
|
113
|
+
key = parsed_json["key"]
|
114
|
+
streak_length = parsed_json["streakLength"]
|
115
|
+
metric_id = parsed_json["metricId"]
|
116
|
+
metric_value = parsed_json["metricValue"]
|
117
|
+
metric_name = parsed_json["metricName"]
|
118
|
+
if parsed_json["currentStreak"].nil?
|
119
|
+
current_streak = nil
|
120
|
+
else
|
121
|
+
current_streak = parsed_json["currentStreak"].to_json
|
122
|
+
current_streak = TrophyApiClient::MetricEventStreakResponse.from_json(json_object: current_streak)
|
123
|
+
end
|
124
|
+
new(
|
125
|
+
achieved_at: achieved_at,
|
126
|
+
id: id,
|
127
|
+
name: name,
|
128
|
+
trigger: trigger,
|
129
|
+
description: description,
|
130
|
+
badge_url: badge_url,
|
131
|
+
key: key,
|
132
|
+
streak_length: streak_length,
|
133
|
+
metric_id: metric_id,
|
134
|
+
metric_value: metric_value,
|
135
|
+
metric_name: metric_name,
|
136
|
+
current_streak: current_streak,
|
137
|
+
additional_properties: struct
|
138
|
+
)
|
139
|
+
end
|
140
|
+
|
141
|
+
# Serialize an instance of CompletedAchievementResponse to a JSON object
|
142
|
+
#
|
143
|
+
# @return [String]
|
144
|
+
def to_json(*_args)
|
145
|
+
@_field_set&.to_json
|
146
|
+
end
|
147
|
+
|
148
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
149
|
+
# hash and check each fields type against the current object's property
|
150
|
+
# definitions.
|
151
|
+
#
|
152
|
+
# @param obj [Object]
|
153
|
+
# @return [Void]
|
154
|
+
def self.validate_raw(obj:)
|
155
|
+
obj.achieved_at&.is_a?(DateTime) != false || raise("Passed value for field obj.achieved_at is not the expected type, validation failed.")
|
156
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
157
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
158
|
+
obj.trigger.is_a?(TrophyApiClient::AchievementResponseTrigger) != false || raise("Passed value for field obj.trigger is not the expected type, validation failed.")
|
159
|
+
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
160
|
+
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
161
|
+
obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
162
|
+
obj.streak_length&.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.")
|
163
|
+
obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
|
164
|
+
obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
|
165
|
+
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
166
|
+
obj.current_streak.nil? || TrophyApiClient::MetricEventStreakResponse.validate_raw(obj: obj.current_streak)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "
|
4
|
-
require_relative "
|
3
|
+
require_relative "completed_achievement_response"
|
4
|
+
require_relative "metric_event_streak_response"
|
5
|
+
require_relative "points_award"
|
5
6
|
require "ostruct"
|
6
7
|
require "json"
|
7
8
|
|
@@ -13,10 +14,13 @@ module TrophyApiClient
|
|
13
14
|
attr_reader :metric_id
|
14
15
|
# @return [Float] The user's new total progress against the metric.
|
15
16
|
attr_reader :total
|
16
|
-
# @return [Array<TrophyApiClient::
|
17
|
+
# @return [Array<TrophyApiClient::CompletedAchievementResponse>] Achievements completed as a result of this event.
|
17
18
|
attr_reader :achievements
|
18
|
-
# @return [TrophyApiClient::
|
19
|
+
# @return [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
19
20
|
attr_reader :current_streak
|
21
|
+
# @return [TrophyApiClient::PointsAward] The points added by this event, and a breakdown of the points awards that added
|
22
|
+
# points.
|
23
|
+
attr_reader :points
|
20
24
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
21
25
|
attr_reader :additional_properties
|
22
26
|
# @return [Object]
|
@@ -28,23 +32,28 @@ module TrophyApiClient
|
|
28
32
|
# @param event_id [String] The unique ID of the event.
|
29
33
|
# @param metric_id [String] The unique ID of the metric that was updated.
|
30
34
|
# @param total [Float] The user's new total progress against the metric.
|
31
|
-
# @param achievements [Array<TrophyApiClient::
|
32
|
-
# @param current_streak [TrophyApiClient::
|
35
|
+
# @param achievements [Array<TrophyApiClient::CompletedAchievementResponse>] Achievements completed as a result of this event.
|
36
|
+
# @param current_streak [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
37
|
+
# @param points [TrophyApiClient::PointsAward] The points added by this event, and a breakdown of the points awards that added
|
38
|
+
# points.
|
33
39
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
34
40
|
# @return [TrophyApiClient::EventResponse]
|
35
|
-
def initialize(event_id:, metric_id:, total:, achievements: OMIT, current_streak: OMIT,
|
41
|
+
def initialize(event_id:, metric_id:, total:, achievements: OMIT, current_streak: OMIT, points: OMIT,
|
42
|
+
additional_properties: nil)
|
36
43
|
@event_id = event_id
|
37
44
|
@metric_id = metric_id
|
38
45
|
@total = total
|
39
46
|
@achievements = achievements if achievements != OMIT
|
40
47
|
@current_streak = current_streak if current_streak != OMIT
|
48
|
+
@points = points if points != OMIT
|
41
49
|
@additional_properties = additional_properties
|
42
50
|
@_field_set = {
|
43
51
|
"eventId": event_id,
|
44
52
|
"metricId": metric_id,
|
45
53
|
"total": total,
|
46
54
|
"achievements": achievements,
|
47
|
-
"currentStreak": current_streak
|
55
|
+
"currentStreak": current_streak,
|
56
|
+
"points": points
|
48
57
|
}.reject do |_k, v|
|
49
58
|
v == OMIT
|
50
59
|
end
|
@@ -62,13 +71,19 @@ module TrophyApiClient
|
|
62
71
|
total = parsed_json["total"]
|
63
72
|
achievements = parsed_json["achievements"]&.map do |item|
|
64
73
|
item = item.to_json
|
65
|
-
TrophyApiClient::
|
74
|
+
TrophyApiClient::CompletedAchievementResponse.from_json(json_object: item)
|
66
75
|
end
|
67
76
|
if parsed_json["currentStreak"].nil?
|
68
77
|
current_streak = nil
|
69
78
|
else
|
70
79
|
current_streak = parsed_json["currentStreak"].to_json
|
71
|
-
current_streak = TrophyApiClient::
|
80
|
+
current_streak = TrophyApiClient::MetricEventStreakResponse.from_json(json_object: current_streak)
|
81
|
+
end
|
82
|
+
if parsed_json["points"].nil?
|
83
|
+
points = nil
|
84
|
+
else
|
85
|
+
points = parsed_json["points"].to_json
|
86
|
+
points = TrophyApiClient::PointsAward.from_json(json_object: points)
|
72
87
|
end
|
73
88
|
new(
|
74
89
|
event_id: event_id,
|
@@ -76,6 +91,7 @@ module TrophyApiClient
|
|
76
91
|
total: total,
|
77
92
|
achievements: achievements,
|
78
93
|
current_streak: current_streak,
|
94
|
+
points: points,
|
79
95
|
additional_properties: struct
|
80
96
|
)
|
81
97
|
end
|
@@ -98,7 +114,8 @@ module TrophyApiClient
|
|
98
114
|
obj.metric_id.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
|
99
115
|
obj.total.is_a?(Float) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
|
100
116
|
obj.achievements&.is_a?(Array) != false || raise("Passed value for field obj.achievements is not the expected type, validation failed.")
|
101
|
-
obj.current_streak.nil? || TrophyApiClient::
|
117
|
+
obj.current_streak.nil? || TrophyApiClient::MetricEventStreakResponse.validate_raw(obj: obj.current_streak)
|
118
|
+
obj.points.nil? || TrophyApiClient::PointsAward.validate_raw(obj: obj.points)
|
102
119
|
end
|
103
120
|
end
|
104
121
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "points_award"
|
4
|
+
require "ostruct"
|
5
|
+
require "json"
|
6
|
+
|
7
|
+
module TrophyApiClient
|
8
|
+
class GetUserPointsResponse
|
9
|
+
# @return [Float] The user's total points
|
10
|
+
attr_reader :total
|
11
|
+
# @return [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
12
|
+
attr_reader :awards
|
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 total [Float] The user's total points
|
22
|
+
# @param awards [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
23
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
24
|
+
# @return [TrophyApiClient::GetUserPointsResponse]
|
25
|
+
def initialize(total: OMIT, awards: OMIT, additional_properties: nil)
|
26
|
+
@total = total if total != OMIT
|
27
|
+
@awards = awards if awards != OMIT
|
28
|
+
@additional_properties = additional_properties
|
29
|
+
@_field_set = { "total": total, "awards": awards }.reject do |_k, v|
|
30
|
+
v == OMIT
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Deserialize a JSON object to an instance of GetUserPointsResponse
|
35
|
+
#
|
36
|
+
# @param json_object [String]
|
37
|
+
# @return [TrophyApiClient::GetUserPointsResponse]
|
38
|
+
def self.from_json(json_object:)
|
39
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
40
|
+
parsed_json = JSON.parse(json_object)
|
41
|
+
total = parsed_json["total"]
|
42
|
+
awards = parsed_json["awards"]&.map do |item|
|
43
|
+
item = item.to_json
|
44
|
+
TrophyApiClient::PointsAward.from_json(json_object: item)
|
45
|
+
end
|
46
|
+
new(
|
47
|
+
total: total,
|
48
|
+
awards: awards,
|
49
|
+
additional_properties: struct
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Serialize an instance of GetUserPointsResponse 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.total&.is_a?(Float) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
|
68
|
+
obj.awards&.is_a?(Array) != false || raise("Passed value for field obj.awards is not the expected type, validation failed.")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "points_award"
|
4
|
+
require "ostruct"
|
5
|
+
require "json"
|
6
|
+
|
7
|
+
module TrophyApiClient
|
8
|
+
class MetricEventPointsResponse
|
9
|
+
# @return [Float] The points added by this event.
|
10
|
+
attr_reader :added
|
11
|
+
# @return [Float] The user's total points
|
12
|
+
attr_reader :total
|
13
|
+
# @return [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
14
|
+
attr_reader :awards
|
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 added [Float] The points added by this event.
|
24
|
+
# @param total [Float] The user's total points
|
25
|
+
# @param awards [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
26
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
27
|
+
# @return [TrophyApiClient::MetricEventPointsResponse]
|
28
|
+
def initialize(added: OMIT, total: OMIT, awards: OMIT, additional_properties: nil)
|
29
|
+
@added = added if added != OMIT
|
30
|
+
@total = total if total != OMIT
|
31
|
+
@awards = awards if awards != OMIT
|
32
|
+
@additional_properties = additional_properties
|
33
|
+
@_field_set = { "added": added, "total": total, "awards": awards }.reject do |_k, v|
|
34
|
+
v == OMIT
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Deserialize a JSON object to an instance of MetricEventPointsResponse
|
39
|
+
#
|
40
|
+
# @param json_object [String]
|
41
|
+
# @return [TrophyApiClient::MetricEventPointsResponse]
|
42
|
+
def self.from_json(json_object:)
|
43
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
44
|
+
parsed_json = JSON.parse(json_object)
|
45
|
+
added = parsed_json["added"]
|
46
|
+
total = parsed_json["total"]
|
47
|
+
awards = parsed_json["awards"]&.map do |item|
|
48
|
+
item = item.to_json
|
49
|
+
TrophyApiClient::PointsAward.from_json(json_object: item)
|
50
|
+
end
|
51
|
+
new(
|
52
|
+
added: added,
|
53
|
+
total: total,
|
54
|
+
awards: awards,
|
55
|
+
additional_properties: struct
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Serialize an instance of MetricEventPointsResponse to a JSON object
|
60
|
+
#
|
61
|
+
# @return [String]
|
62
|
+
def to_json(*_args)
|
63
|
+
@_field_set&.to_json
|
64
|
+
end
|
65
|
+
|
66
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
67
|
+
# hash and check each fields type against the current object's property
|
68
|
+
# definitions.
|
69
|
+
#
|
70
|
+
# @param obj [Object]
|
71
|
+
# @return [Void]
|
72
|
+
def self.validate_raw(obj:)
|
73
|
+
obj.added&.is_a?(Float) != false || raise("Passed value for field obj.added is not the expected type, validation failed.")
|
74
|
+
obj.total&.is_a?(Float) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
|
75
|
+
obj.awards&.is_a?(Array) != false || raise("Passed value for field obj.awards is not the expected type, validation failed.")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -5,8 +5,8 @@ require "ostruct"
|
|
5
5
|
require "json"
|
6
6
|
|
7
7
|
module TrophyApiClient
|
8
|
-
# An object representing the user's streak after
|
9
|
-
class
|
8
|
+
# An object representing the user's streak after sending a metric event.
|
9
|
+
class MetricEventStreakResponse
|
10
10
|
# @return [Boolean] Whether this metric event increased the user's streak length.
|
11
11
|
attr_reader :extended
|
12
12
|
# @return [Integer] The length of the user's current streak.
|
@@ -37,7 +37,7 @@ module TrophyApiClient
|
|
37
37
|
# @param period_end [String] The end date of the current streak period.
|
38
38
|
# @param expires [String] The date the streak will expire if the user does not increment a metric.
|
39
39
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
40
|
-
# @return [TrophyApiClient::
|
40
|
+
# @return [TrophyApiClient::MetricEventStreakResponse]
|
41
41
|
def initialize(length:, frequency:, extended: OMIT, started: OMIT, period_start: OMIT, period_end: OMIT,
|
42
42
|
expires: OMIT, additional_properties: nil)
|
43
43
|
@extended = extended if extended != OMIT
|
@@ -61,10 +61,10 @@ module TrophyApiClient
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
# Deserialize a JSON object to an instance of
|
64
|
+
# Deserialize a JSON object to an instance of MetricEventStreakResponse
|
65
65
|
#
|
66
66
|
# @param json_object [String]
|
67
|
-
# @return [TrophyApiClient::
|
67
|
+
# @return [TrophyApiClient::MetricEventStreakResponse]
|
68
68
|
def self.from_json(json_object:)
|
69
69
|
struct = JSON.parse(json_object, object_class: OpenStruct)
|
70
70
|
parsed_json = JSON.parse(json_object)
|
@@ -87,7 +87,7 @@ module TrophyApiClient
|
|
87
87
|
)
|
88
88
|
end
|
89
89
|
|
90
|
-
# Serialize an instance of
|
90
|
+
# Serialize an instance of MetricEventStreakResponse to a JSON object
|
91
91
|
#
|
92
92
|
# @return [String]
|
93
93
|
def to_json(*_args)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "metric_status"
|
4
|
-
require_relative "
|
4
|
+
require_relative "completed_achievement_response"
|
5
5
|
require "ostruct"
|
6
6
|
require "json"
|
7
7
|
|
@@ -17,7 +17,7 @@ module TrophyApiClient
|
|
17
17
|
attr_reader :status
|
18
18
|
# @return [Float] The user's current total for the metric.
|
19
19
|
attr_reader :current
|
20
|
-
# @return [Array<TrophyApiClient::
|
20
|
+
# @return [Array<TrophyApiClient::CompletedAchievementResponse>] A list of the metric's achievements and the user's progress towards each.
|
21
21
|
attr_reader :achievements
|
22
22
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
23
23
|
attr_reader :additional_properties
|
@@ -32,7 +32,7 @@ module TrophyApiClient
|
|
32
32
|
# @param name [String] The name of the metric.
|
33
33
|
# @param status [TrophyApiClient::MetricStatus] The status of the metric.
|
34
34
|
# @param current [Float] The user's current total for the metric.
|
35
|
-
# @param achievements [Array<TrophyApiClient::
|
35
|
+
# @param achievements [Array<TrophyApiClient::CompletedAchievementResponse>] A list of the metric's achievements and the user's progress towards each.
|
36
36
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
37
37
|
# @return [TrophyApiClient::MetricResponse]
|
38
38
|
def initialize(id:, key:, name:, status:, current:, achievements:, additional_properties: nil)
|
@@ -67,7 +67,7 @@ module TrophyApiClient
|
|
67
67
|
current = parsed_json["current"]
|
68
68
|
achievements = parsed_json["achievements"]&.map do |item|
|
69
69
|
item = item.to_json
|
70
|
-
TrophyApiClient::
|
70
|
+
TrophyApiClient::CompletedAchievementResponse.from_json(json_object: item)
|
71
71
|
end
|
72
72
|
new(
|
73
73
|
id: id,
|