trophy_api_client 1.0.16 → 1.0.17
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 +9 -5
- data/lib/trophy_api_client/metrics/client.rb +26 -8
- data/lib/trophy_api_client/points/client.rb +37 -33
- data/lib/trophy_api_client/types/achievement_completion_response.rb +16 -2
- data/lib/trophy_api_client/types/achievement_with_stats_response.rb +39 -9
- data/lib/trophy_api_client/types/achievement_with_stats_response_event_attribute.rb +69 -0
- data/lib/trophy_api_client/types/achievement_with_stats_response_user_attributes_item.rb +67 -0
- data/lib/trophy_api_client/types/event_response.rb +6 -11
- data/lib/trophy_api_client/types/get_user_points_response.rb +41 -6
- data/lib/trophy_api_client/types/metric_event_points_response.rb +43 -6
- data/lib/trophy_api_client/types/points_system_response.rb +98 -0
- data/lib/trophy_api_client/types/points_trigger_response.rb +31 -1
- data/lib/trophy_api_client/types/points_trigger_response_event_attribute.rb +67 -0
- data/lib/trophy_api_client/types/points_trigger_response_user_attributes_item.rb +67 -0
- data/lib/trophy_api_client/types/updated_user.rb +12 -2
- data/lib/trophy_api_client/types/upserted_user.rb +12 -2
- data/lib/trophy_api_client/types/user.rb +12 -2
- data/lib/trophy_api_client/users/client.rb +52 -30
- data/lib/trophy_api_client/version.rb +1 -1
- data/lib/types_export.rb +5 -0
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b47c1dffc5c157c7dffe0f36b0ab3dd3ddd2a156b9df8e9a627df0bc76964a69
|
4
|
+
data.tar.gz: ebd77639b480e7c9a86ec6d66d7df2d8a3573f24eb41b73d2f4f53a86c8a7c99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3f96b20a61f733c3aa9dab75996649d880857be9afdd41fd28982875bbac47bd0222499bbd5a3ac5738e099eb4e395ccb3d103c47aad07573e4756848b893ca
|
7
|
+
data.tar.gz: 0bbedd740ea253b4b9b5a19a335de5e153fabb163060040723a729870d7cb629451734ab2f9a58be6388d3400f73007526ab0e6394ccb68d3d6a1ebe30870623
|
data/lib/gemconfig.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../requests"
|
4
4
|
require_relative "../types/achievement_with_stats_response"
|
5
5
|
require "json"
|
6
|
-
require_relative "../types/
|
6
|
+
require_relative "../types/upserted_user"
|
7
7
|
require_relative "../types/achievement_completion_response"
|
8
8
|
require "async"
|
9
9
|
|
@@ -56,12 +56,14 @@ module TrophyApiClient
|
|
56
56
|
# Mark an achievement as completed for a user.
|
57
57
|
#
|
58
58
|
# @param key [String] Unique reference of the achievement as set when created.
|
59
|
-
# @param user [Hash] The user that completed the achievement.Request of type TrophyApiClient::
|
59
|
+
# @param user [Hash] The user that completed the achievement.Request of type TrophyApiClient::UpsertedUser, as a Hash
|
60
|
+
# * :id (String)
|
60
61
|
# * :email (String)
|
61
62
|
# * :name (String)
|
62
63
|
# * :tz (String)
|
63
64
|
# * :device_tokens (Array<String>)
|
64
65
|
# * :subscribe_to_emails (Boolean)
|
66
|
+
# * :attributes (Hash{String => String})
|
65
67
|
# @param request_options [TrophyApiClient::RequestOptions]
|
66
68
|
# @return [TrophyApiClient::AchievementCompletionResponse]
|
67
69
|
# @example
|
@@ -70,7 +72,7 @@ module TrophyApiClient
|
|
70
72
|
# environment: TrophyApiClient::Environment::DEFAULT,
|
71
73
|
# api_key: "YOUR_API_KEY"
|
72
74
|
# )
|
73
|
-
# api.achievements.complete(key: "finish-onboarding", user: { email: "user@example.com", tz: "Europe/London" })
|
75
|
+
# api.achievements.complete(key: "finish-onboarding", user: { email: "user@example.com", tz: "Europe/London", id: "user-id" })
|
74
76
|
def complete(key:, user:, request_options: nil)
|
75
77
|
response = @request_client.conn.post do |req|
|
76
78
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
@@ -140,12 +142,14 @@ module TrophyApiClient
|
|
140
142
|
# Mark an achievement as completed for a user.
|
141
143
|
#
|
142
144
|
# @param key [String] Unique reference of the achievement as set when created.
|
143
|
-
# @param user [Hash] The user that completed the achievement.Request of type TrophyApiClient::
|
145
|
+
# @param user [Hash] The user that completed the achievement.Request of type TrophyApiClient::UpsertedUser, as a Hash
|
146
|
+
# * :id (String)
|
144
147
|
# * :email (String)
|
145
148
|
# * :name (String)
|
146
149
|
# * :tz (String)
|
147
150
|
# * :device_tokens (Array<String>)
|
148
151
|
# * :subscribe_to_emails (Boolean)
|
152
|
+
# * :attributes (Hash{String => String})
|
149
153
|
# @param request_options [TrophyApiClient::RequestOptions]
|
150
154
|
# @return [TrophyApiClient::AchievementCompletionResponse]
|
151
155
|
# @example
|
@@ -154,7 +158,7 @@ module TrophyApiClient
|
|
154
158
|
# environment: TrophyApiClient::Environment::DEFAULT,
|
155
159
|
# api_key: "YOUR_API_KEY"
|
156
160
|
# )
|
157
|
-
# api.achievements.complete(key: "finish-onboarding", user: { email: "user@example.com", tz: "Europe/London" })
|
161
|
+
# api.achievements.complete(key: "finish-onboarding", user: { email: "user@example.com", tz: "Europe/London", id: "user-id" })
|
158
162
|
def complete(key:, user:, request_options: nil)
|
159
163
|
Async do
|
160
164
|
response = @request_client.conn.post do |req|
|
@@ -26,7 +26,10 @@ module TrophyApiClient
|
|
26
26
|
# * :tz (String)
|
27
27
|
# * :device_tokens (Array<String>)
|
28
28
|
# * :subscribe_to_emails (Boolean)
|
29
|
+
# * :attributes (Hash{String => String})
|
29
30
|
# @param value [Float] The value to add to the user's current total for the given metric.
|
31
|
+
# @param attributes [Hash{String => String}] Event attributes as key-value pairs. Keys must match existing event attributes
|
32
|
+
# set up in the Trophy dashboard.
|
30
33
|
# @param request_options [TrophyApiClient::RequestOptions]
|
31
34
|
# @return [TrophyApiClient::EventResponse]
|
32
35
|
# @example
|
@@ -37,10 +40,11 @@ module TrophyApiClient
|
|
37
40
|
# )
|
38
41
|
# api.metrics.event(
|
39
42
|
# key: "words-written",
|
40
|
-
# user: { email: "user@example.com", tz: "Europe/London", id: "18" },
|
41
|
-
# value: 750
|
43
|
+
# user: { email: "user@example.com", tz: "Europe/London", attributes: { "department": "engineering", "role": "developer" }, id: "18" },
|
44
|
+
# value: 750,
|
45
|
+
# attributes: { "category": "writing", "source": "mobile-app" }
|
42
46
|
# )
|
43
|
-
def event(key:, user:, value:, request_options: nil)
|
47
|
+
def event(key:, user:, value:, attributes: nil, request_options: nil)
|
44
48
|
response = @request_client.conn.post do |req|
|
45
49
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
46
50
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
@@ -52,7 +56,12 @@ module TrophyApiClient
|
|
52
56
|
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
53
57
|
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
54
58
|
end
|
55
|
-
req.body = {
|
59
|
+
req.body = {
|
60
|
+
**(request_options&.additional_body_parameters || {}),
|
61
|
+
user: user,
|
62
|
+
value: value,
|
63
|
+
attributes: attributes
|
64
|
+
}.compact
|
56
65
|
req.url "#{@request_client.get_url(request_options: request_options)}/metrics/#{key}/event"
|
57
66
|
end
|
58
67
|
TrophyApiClient::EventResponse.from_json(json_object: response.body)
|
@@ -79,7 +88,10 @@ module TrophyApiClient
|
|
79
88
|
# * :tz (String)
|
80
89
|
# * :device_tokens (Array<String>)
|
81
90
|
# * :subscribe_to_emails (Boolean)
|
91
|
+
# * :attributes (Hash{String => String})
|
82
92
|
# @param value [Float] The value to add to the user's current total for the given metric.
|
93
|
+
# @param attributes [Hash{String => String}] Event attributes as key-value pairs. Keys must match existing event attributes
|
94
|
+
# set up in the Trophy dashboard.
|
83
95
|
# @param request_options [TrophyApiClient::RequestOptions]
|
84
96
|
# @return [TrophyApiClient::EventResponse]
|
85
97
|
# @example
|
@@ -90,10 +102,11 @@ module TrophyApiClient
|
|
90
102
|
# )
|
91
103
|
# api.metrics.event(
|
92
104
|
# key: "words-written",
|
93
|
-
# user: { email: "user@example.com", tz: "Europe/London", id: "18" },
|
94
|
-
# value: 750
|
105
|
+
# user: { email: "user@example.com", tz: "Europe/London", attributes: { "department": "engineering", "role": "developer" }, id: "18" },
|
106
|
+
# value: 750,
|
107
|
+
# attributes: { "category": "writing", "source": "mobile-app" }
|
95
108
|
# )
|
96
|
-
def event(key:, user:, value:, request_options: nil)
|
109
|
+
def event(key:, user:, value:, attributes: nil, request_options: nil)
|
97
110
|
Async do
|
98
111
|
response = @request_client.conn.post do |req|
|
99
112
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
@@ -106,7 +119,12 @@ module TrophyApiClient
|
|
106
119
|
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
107
120
|
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
108
121
|
end
|
109
|
-
req.body = {
|
122
|
+
req.body = {
|
123
|
+
**(request_options&.additional_body_parameters || {}),
|
124
|
+
user: user,
|
125
|
+
value: value,
|
126
|
+
attributes: attributes
|
127
|
+
}.compact
|
110
128
|
req.url "#{@request_client.get_url(request_options: request_options)}/metrics/#{key}/event"
|
111
129
|
end
|
112
130
|
TrophyApiClient::EventResponse.from_json(json_object: response.body)
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative "../../requests"
|
4
4
|
require_relative "../types/points_summary_response"
|
5
5
|
require "json"
|
6
|
-
require_relative "../types/
|
6
|
+
require_relative "../types/points_system_response"
|
7
7
|
require "async"
|
8
8
|
|
9
9
|
module TrophyApiClient
|
@@ -19,6 +19,10 @@ module TrophyApiClient
|
|
19
19
|
|
20
20
|
# Get a breakdown of the number of users with points in each range.
|
21
21
|
#
|
22
|
+
# @param key [String] Key of the points system.
|
23
|
+
# @param user_attributes [String] Optional colon-delimited user attribute filters in the format
|
24
|
+
# attributeKey:value,attributeKey:value. Only users matching ALL specified
|
25
|
+
# attributes will be included in the points breakdown.
|
22
26
|
# @param request_options [TrophyApiClient::RequestOptions]
|
23
27
|
# @return [TrophyApiClient::POINTS_SUMMARY_RESPONSE]
|
24
28
|
# @example
|
@@ -27,8 +31,8 @@ module TrophyApiClient
|
|
27
31
|
# environment: TrophyApiClient::Environment::DEFAULT,
|
28
32
|
# api_key: "YOUR_API_KEY"
|
29
33
|
# )
|
30
|
-
# api.points.summary
|
31
|
-
def summary(request_options: nil)
|
34
|
+
# api.points.summary(key: "points-system-key", user_attributes: "plan-type:premium,region:us-east")
|
35
|
+
def summary(key:, user_attributes: nil, request_options: nil)
|
32
36
|
response = @request_client.conn.get do |req|
|
33
37
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
34
38
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
@@ -37,13 +41,14 @@ module TrophyApiClient
|
|
37
41
|
**@request_client.get_headers,
|
38
42
|
**(request_options&.additional_headers || {})
|
39
43
|
}.compact
|
40
|
-
|
41
|
-
|
42
|
-
|
44
|
+
req.params = {
|
45
|
+
**(request_options&.additional_query_parameters || {}),
|
46
|
+
"userAttributes": user_attributes
|
47
|
+
}.compact
|
43
48
|
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
44
49
|
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
45
50
|
end
|
46
|
-
req.url "#{@request_client.get_url(request_options: request_options)}/points/summary"
|
51
|
+
req.url "#{@request_client.get_url(request_options: request_options)}/points/#{key}/summary"
|
47
52
|
end
|
48
53
|
parsed_json = JSON.parse(response.body)
|
49
54
|
parsed_json&.map do |item|
|
@@ -52,18 +57,19 @@ module TrophyApiClient
|
|
52
57
|
end
|
53
58
|
end
|
54
59
|
|
55
|
-
# Get
|
60
|
+
# Get a points system with all its triggers.
|
56
61
|
#
|
62
|
+
# @param key [String] Key of the points system.
|
57
63
|
# @param request_options [TrophyApiClient::RequestOptions]
|
58
|
-
# @return [
|
64
|
+
# @return [TrophyApiClient::PointsSystemResponse]
|
59
65
|
# @example
|
60
66
|
# api = TrophyApiClient::Client.new(
|
61
67
|
# base_url: "https://api.example.com",
|
62
68
|
# environment: TrophyApiClient::Environment::DEFAULT,
|
63
69
|
# api_key: "YOUR_API_KEY"
|
64
70
|
# )
|
65
|
-
# api.points.
|
66
|
-
def
|
71
|
+
# api.points.system(key: "points-system-key")
|
72
|
+
def system(key:, request_options: nil)
|
67
73
|
response = @request_client.conn.get do |req|
|
68
74
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
69
75
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
@@ -78,13 +84,9 @@ module TrophyApiClient
|
|
78
84
|
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
79
85
|
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
80
86
|
end
|
81
|
-
req.url "#{@request_client.get_url(request_options: request_options)}/points
|
82
|
-
end
|
83
|
-
parsed_json = JSON.parse(response.body)
|
84
|
-
parsed_json&.map do |item|
|
85
|
-
item = item.to_json
|
86
|
-
TrophyApiClient::PointsTriggerResponse.from_json(json_object: item)
|
87
|
+
req.url "#{@request_client.get_url(request_options: request_options)}/points/#{key}"
|
87
88
|
end
|
89
|
+
TrophyApiClient::PointsSystemResponse.from_json(json_object: response.body)
|
88
90
|
end
|
89
91
|
end
|
90
92
|
|
@@ -100,6 +102,10 @@ module TrophyApiClient
|
|
100
102
|
|
101
103
|
# Get a breakdown of the number of users with points in each range.
|
102
104
|
#
|
105
|
+
# @param key [String] Key of the points system.
|
106
|
+
# @param user_attributes [String] Optional colon-delimited user attribute filters in the format
|
107
|
+
# attributeKey:value,attributeKey:value. Only users matching ALL specified
|
108
|
+
# attributes will be included in the points breakdown.
|
103
109
|
# @param request_options [TrophyApiClient::RequestOptions]
|
104
110
|
# @return [TrophyApiClient::POINTS_SUMMARY_RESPONSE]
|
105
111
|
# @example
|
@@ -108,8 +114,8 @@ module TrophyApiClient
|
|
108
114
|
# environment: TrophyApiClient::Environment::DEFAULT,
|
109
115
|
# api_key: "YOUR_API_KEY"
|
110
116
|
# )
|
111
|
-
# api.points.summary
|
112
|
-
def summary(request_options: nil)
|
117
|
+
# api.points.summary(key: "points-system-key", user_attributes: "plan-type:premium,region:us-east")
|
118
|
+
def summary(key:, user_attributes: nil, request_options: nil)
|
113
119
|
Async do
|
114
120
|
response = @request_client.conn.get do |req|
|
115
121
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
@@ -119,13 +125,14 @@ module TrophyApiClient
|
|
119
125
|
**@request_client.get_headers,
|
120
126
|
**(request_options&.additional_headers || {})
|
121
127
|
}.compact
|
122
|
-
|
123
|
-
|
124
|
-
|
128
|
+
req.params = {
|
129
|
+
**(request_options&.additional_query_parameters || {}),
|
130
|
+
"userAttributes": user_attributes
|
131
|
+
}.compact
|
125
132
|
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
126
133
|
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
127
134
|
end
|
128
|
-
req.url "#{@request_client.get_url(request_options: request_options)}/points/summary"
|
135
|
+
req.url "#{@request_client.get_url(request_options: request_options)}/points/#{key}/summary"
|
129
136
|
end
|
130
137
|
parsed_json = JSON.parse(response.body)
|
131
138
|
parsed_json&.map do |item|
|
@@ -135,18 +142,19 @@ module TrophyApiClient
|
|
135
142
|
end
|
136
143
|
end
|
137
144
|
|
138
|
-
# Get
|
145
|
+
# Get a points system with all its triggers.
|
139
146
|
#
|
147
|
+
# @param key [String] Key of the points system.
|
140
148
|
# @param request_options [TrophyApiClient::RequestOptions]
|
141
|
-
# @return [
|
149
|
+
# @return [TrophyApiClient::PointsSystemResponse]
|
142
150
|
# @example
|
143
151
|
# api = TrophyApiClient::Client.new(
|
144
152
|
# base_url: "https://api.example.com",
|
145
153
|
# environment: TrophyApiClient::Environment::DEFAULT,
|
146
154
|
# api_key: "YOUR_API_KEY"
|
147
155
|
# )
|
148
|
-
# api.points.
|
149
|
-
def
|
156
|
+
# api.points.system(key: "points-system-key")
|
157
|
+
def system(key:, request_options: nil)
|
150
158
|
Async do
|
151
159
|
response = @request_client.conn.get do |req|
|
152
160
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
@@ -162,13 +170,9 @@ module TrophyApiClient
|
|
162
170
|
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
163
171
|
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
164
172
|
end
|
165
|
-
req.url "#{@request_client.get_url(request_options: request_options)}/points
|
166
|
-
end
|
167
|
-
parsed_json = JSON.parse(response.body)
|
168
|
-
parsed_json&.map do |item|
|
169
|
-
item = item.to_json
|
170
|
-
TrophyApiClient::PointsTriggerResponse.from_json(json_object: item)
|
173
|
+
req.url "#{@request_client.get_url(request_options: request_options)}/points/#{key}"
|
171
174
|
end
|
175
|
+
TrophyApiClient::PointsSystemResponse.from_json(json_object: response.body)
|
172
176
|
end
|
173
177
|
end
|
174
178
|
end
|
@@ -10,6 +10,9 @@ module TrophyApiClient
|
|
10
10
|
attr_reader :completion_id
|
11
11
|
# @return [TrophyApiClient::CompletedAchievementResponse]
|
12
12
|
attr_reader :achievement
|
13
|
+
# @return [Hash{String => TrophyApiClient::MetricEventPointsResponse}] A map of points systems by key that were affected by this achievement
|
14
|
+
# completion.
|
15
|
+
attr_reader :points
|
13
16
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
14
17
|
attr_reader :additional_properties
|
15
18
|
# @return [Object]
|
@@ -20,13 +23,18 @@ module TrophyApiClient
|
|
20
23
|
|
21
24
|
# @param completion_id [String] The unique ID of the completion.
|
22
25
|
# @param achievement [TrophyApiClient::CompletedAchievementResponse]
|
26
|
+
# @param points [Hash{String => TrophyApiClient::MetricEventPointsResponse}] A map of points systems by key that were affected by this achievement
|
27
|
+
# completion.
|
23
28
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
24
29
|
# @return [TrophyApiClient::AchievementCompletionResponse]
|
25
|
-
def initialize(completion_id:, achievement:, additional_properties: nil)
|
30
|
+
def initialize(completion_id:, achievement:, points: OMIT, additional_properties: nil)
|
26
31
|
@completion_id = completion_id
|
27
32
|
@achievement = achievement
|
33
|
+
@points = points if points != OMIT
|
28
34
|
@additional_properties = additional_properties
|
29
|
-
@_field_set = { "completionId": completion_id, "achievement": achievement }
|
35
|
+
@_field_set = { "completionId": completion_id, "achievement": achievement, "points": points }.reject do |_k, v|
|
36
|
+
v == OMIT
|
37
|
+
end
|
30
38
|
end
|
31
39
|
|
32
40
|
# Deserialize a JSON object to an instance of AchievementCompletionResponse
|
@@ -43,9 +51,14 @@ module TrophyApiClient
|
|
43
51
|
achievement = parsed_json["achievement"].to_json
|
44
52
|
achievement = TrophyApiClient::CompletedAchievementResponse.from_json(json_object: achievement)
|
45
53
|
end
|
54
|
+
points = parsed_json["points"]&.transform_values do |value|
|
55
|
+
value = value.to_json
|
56
|
+
TrophyApiClient::MetricEventPointsResponse.from_json(json_object: value)
|
57
|
+
end
|
46
58
|
new(
|
47
59
|
completion_id: completion_id,
|
48
60
|
achievement: achievement,
|
61
|
+
points: points,
|
49
62
|
additional_properties: struct
|
50
63
|
)
|
51
64
|
end
|
@@ -66,6 +79,7 @@ module TrophyApiClient
|
|
66
79
|
def self.validate_raw(obj:)
|
67
80
|
obj.completion_id.is_a?(String) != false || raise("Passed value for field obj.completion_id is not the expected type, validation failed.")
|
68
81
|
TrophyApiClient::CompletedAchievementResponse.validate_raw(obj: obj.achievement)
|
82
|
+
obj.points&.is_a?(Hash) != false || raise("Passed value for field obj.points is not the expected type, validation failed.")
|
69
83
|
end
|
70
84
|
end
|
71
85
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "achievement_with_stats_response_user_attributes_item"
|
4
|
+
require_relative "achievement_with_stats_response_event_attribute"
|
3
5
|
require_relative "achievement_response_trigger"
|
4
6
|
require_relative "metric_event_streak_response"
|
5
7
|
require "ostruct"
|
@@ -10,7 +12,13 @@ module TrophyApiClient
|
|
10
12
|
# @return [Integer] The number of users who have completed this achievement.
|
11
13
|
attr_reader :completions
|
12
14
|
# @return [Float] The percentage of all users who have completed this achievement.
|
13
|
-
attr_reader :
|
15
|
+
attr_reader :rarity
|
16
|
+
# @return [Array<TrophyApiClient::AchievementWithStatsResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
|
17
|
+
# Only present if the achievement has user attribute filters configured.
|
18
|
+
attr_reader :user_attributes
|
19
|
+
# @return [TrophyApiClient::AchievementWithStatsResponseEventAttribute] Event attribute filter that must be met for this achievement to be completed.
|
20
|
+
# Only present if the achievement has an event filter configured.
|
21
|
+
attr_reader :event_attribute
|
14
22
|
# @return [String] The unique ID of the achievement.
|
15
23
|
attr_reader :id
|
16
24
|
# @return [String] The name of this achievement.
|
@@ -47,7 +55,11 @@ module TrophyApiClient
|
|
47
55
|
OMIT = Object.new
|
48
56
|
|
49
57
|
# @param completions [Integer] The number of users who have completed this achievement.
|
50
|
-
# @param
|
58
|
+
# @param rarity [Float] The percentage of all users who have completed this achievement.
|
59
|
+
# @param user_attributes [Array<TrophyApiClient::AchievementWithStatsResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
|
60
|
+
# Only present if the achievement has user attribute filters configured.
|
61
|
+
# @param event_attribute [TrophyApiClient::AchievementWithStatsResponseEventAttribute] Event attribute filter that must be met for this achievement to be completed.
|
62
|
+
# Only present if the achievement has an event filter configured.
|
51
63
|
# @param id [String] The unique ID of the achievement.
|
52
64
|
# @param name [String] The name of this achievement.
|
53
65
|
# @param trigger [TrophyApiClient::AchievementResponseTrigger] The trigger of the achievement.
|
@@ -66,10 +78,12 @@ module TrophyApiClient
|
|
66
78
|
# @param current_streak [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
|
67
79
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
68
80
|
# @return [TrophyApiClient::AchievementWithStatsResponse]
|
69
|
-
def initialize(id:, name:, trigger:, completions: 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)
|
81
|
+
def initialize(id:, name:, trigger:, completions: OMIT, rarity: OMIT, user_attributes: OMIT, event_attribute: OMIT,
|
82
|
+
description: OMIT, badge_url: OMIT, key: OMIT, streak_length: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, current_streak: OMIT, additional_properties: nil)
|
71
83
|
@completions = completions if completions != OMIT
|
72
|
-
@
|
84
|
+
@rarity = rarity if rarity != OMIT
|
85
|
+
@user_attributes = user_attributes if user_attributes != OMIT
|
86
|
+
@event_attribute = event_attribute if event_attribute != OMIT
|
73
87
|
@id = id
|
74
88
|
@name = name
|
75
89
|
@trigger = trigger
|
@@ -84,7 +98,9 @@ module TrophyApiClient
|
|
84
98
|
@additional_properties = additional_properties
|
85
99
|
@_field_set = {
|
86
100
|
"completions": completions,
|
87
|
-
"
|
101
|
+
"rarity": rarity,
|
102
|
+
"userAttributes": user_attributes,
|
103
|
+
"eventAttribute": event_attribute,
|
88
104
|
"id": id,
|
89
105
|
"name": name,
|
90
106
|
"trigger": trigger,
|
@@ -109,7 +125,17 @@ module TrophyApiClient
|
|
109
125
|
struct = JSON.parse(json_object, object_class: OpenStruct)
|
110
126
|
parsed_json = JSON.parse(json_object)
|
111
127
|
completions = parsed_json["completions"]
|
112
|
-
|
128
|
+
rarity = parsed_json["rarity"]
|
129
|
+
user_attributes = parsed_json["userAttributes"]&.map do |item|
|
130
|
+
item = item.to_json
|
131
|
+
TrophyApiClient::AchievementWithStatsResponseUserAttributesItem.from_json(json_object: item)
|
132
|
+
end
|
133
|
+
if parsed_json["eventAttribute"].nil?
|
134
|
+
event_attribute = nil
|
135
|
+
else
|
136
|
+
event_attribute = parsed_json["eventAttribute"].to_json
|
137
|
+
event_attribute = TrophyApiClient::AchievementWithStatsResponseEventAttribute.from_json(json_object: event_attribute)
|
138
|
+
end
|
113
139
|
id = parsed_json["id"]
|
114
140
|
name = parsed_json["name"]
|
115
141
|
trigger = parsed_json["trigger"]
|
@@ -128,7 +154,9 @@ module TrophyApiClient
|
|
128
154
|
end
|
129
155
|
new(
|
130
156
|
completions: completions,
|
131
|
-
|
157
|
+
rarity: rarity,
|
158
|
+
user_attributes: user_attributes,
|
159
|
+
event_attribute: event_attribute,
|
132
160
|
id: id,
|
133
161
|
name: name,
|
134
162
|
trigger: trigger,
|
@@ -159,7 +187,9 @@ module TrophyApiClient
|
|
159
187
|
# @return [Void]
|
160
188
|
def self.validate_raw(obj:)
|
161
189
|
obj.completions&.is_a?(Integer) != false || raise("Passed value for field obj.completions is not the expected type, validation failed.")
|
162
|
-
obj.
|
190
|
+
obj.rarity&.is_a?(Float) != false || raise("Passed value for field obj.rarity is not the expected type, validation failed.")
|
191
|
+
obj.user_attributes&.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.")
|
192
|
+
obj.event_attribute.nil? || TrophyApiClient::AchievementWithStatsResponseEventAttribute.validate_raw(obj: obj.event_attribute)
|
163
193
|
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
164
194
|
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
165
195
|
obj.trigger.is_a?(TrophyApiClient::AchievementResponseTrigger) != false || raise("Passed value for field obj.trigger is not the expected type, validation failed.")
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "ostruct"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module TrophyApiClient
|
7
|
+
# Event attribute filter that must be met for this achievement to be completed.
|
8
|
+
# Only present if the achievement has an event filter configured.
|
9
|
+
class AchievementWithStatsResponseEventAttribute
|
10
|
+
# @return [String] The key of the event attribute.
|
11
|
+
attr_reader :key
|
12
|
+
# @return [String] The value of the event attribute.
|
13
|
+
attr_reader :value
|
14
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
15
|
+
attr_reader :additional_properties
|
16
|
+
# @return [Object]
|
17
|
+
attr_reader :_field_set
|
18
|
+
protected :_field_set
|
19
|
+
|
20
|
+
OMIT = Object.new
|
21
|
+
|
22
|
+
# @param key [String] The key of the event attribute.
|
23
|
+
# @param value [String] The value of the event attribute.
|
24
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
25
|
+
# @return [TrophyApiClient::AchievementWithStatsResponseEventAttribute]
|
26
|
+
def initialize(key:, value:, additional_properties: nil)
|
27
|
+
@key = key
|
28
|
+
@value = value
|
29
|
+
@additional_properties = additional_properties
|
30
|
+
@_field_set = { "key": key, "value": value }
|
31
|
+
end
|
32
|
+
|
33
|
+
# Deserialize a JSON object to an instance of
|
34
|
+
# AchievementWithStatsResponseEventAttribute
|
35
|
+
#
|
36
|
+
# @param json_object [String]
|
37
|
+
# @return [TrophyApiClient::AchievementWithStatsResponseEventAttribute]
|
38
|
+
def self.from_json(json_object:)
|
39
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
40
|
+
parsed_json = JSON.parse(json_object)
|
41
|
+
key = parsed_json["key"]
|
42
|
+
value = parsed_json["value"]
|
43
|
+
new(
|
44
|
+
key: key,
|
45
|
+
value: value,
|
46
|
+
additional_properties: struct
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Serialize an instance of AchievementWithStatsResponseEventAttribute to a JSON
|
51
|
+
# object
|
52
|
+
#
|
53
|
+
# @return [String]
|
54
|
+
def to_json(*_args)
|
55
|
+
@_field_set&.to_json
|
56
|
+
end
|
57
|
+
|
58
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
59
|
+
# hash and check each fields type against the current object's property
|
60
|
+
# definitions.
|
61
|
+
#
|
62
|
+
# @param obj [Object]
|
63
|
+
# @return [Void]
|
64
|
+
def self.validate_raw(obj:)
|
65
|
+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
66
|
+
obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "ostruct"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module TrophyApiClient
|
7
|
+
class AchievementWithStatsResponseUserAttributesItem
|
8
|
+
# @return [String] The key of the user attribute.
|
9
|
+
attr_reader :key
|
10
|
+
# @return [String] The value of the user attribute.
|
11
|
+
attr_reader :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 key [String] The key of the user attribute.
|
21
|
+
# @param value [String] The value of the user attribute.
|
22
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
23
|
+
# @return [TrophyApiClient::AchievementWithStatsResponseUserAttributesItem]
|
24
|
+
def initialize(key:, value:, additional_properties: nil)
|
25
|
+
@key = key
|
26
|
+
@value = value
|
27
|
+
@additional_properties = additional_properties
|
28
|
+
@_field_set = { "key": key, "value": value }
|
29
|
+
end
|
30
|
+
|
31
|
+
# Deserialize a JSON object to an instance of
|
32
|
+
# AchievementWithStatsResponseUserAttributesItem
|
33
|
+
#
|
34
|
+
# @param json_object [String]
|
35
|
+
# @return [TrophyApiClient::AchievementWithStatsResponseUserAttributesItem]
|
36
|
+
def self.from_json(json_object:)
|
37
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
38
|
+
parsed_json = JSON.parse(json_object)
|
39
|
+
key = parsed_json["key"]
|
40
|
+
value = parsed_json["value"]
|
41
|
+
new(
|
42
|
+
key: key,
|
43
|
+
value: value,
|
44
|
+
additional_properties: struct
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Serialize an instance of AchievementWithStatsResponseUserAttributesItem 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.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
64
|
+
obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|