Skip to content

Commit 04cb8f3

Browse files
Automatically update Ruby SDK
1 parent aca2048 commit 04cb8f3

27 files changed

+526
-349
lines changed

lib/gemconfig.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module TrophyApiClient
44
module Gemconfig
5-
VERSION = "1.2.1"
5+
VERSION = "1.3.4"
66
AUTHORS = ["Trophy Labs, Inc"].freeze
77
EMAIL = ""
88
SUMMARY = "Ruby library for the Trophy API."

lib/trophy_api_client/leaderboards/types/leaderboards_all_response_item.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ class LeaderboardsAllResponseItem
1919
attr_reader :key
2020
# @return [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
2121
attr_reader :rank_by
22-
# @return [String] The key of the attribute to break down this leaderboard by.
22+
# @return [String] Deprecated. The key of the attribute to break down this leaderboard by.
2323
attr_reader :breakdown_attribute
24+
# @return [Array<String>] The user attribute keys that this leaderboard is broken down by.
25+
attr_reader :breakdown_attributes
2426
# @return [String] The key of the metric to rank by, if rankBy is 'metric'.
2527
attr_reader :metric_key
2628
# @return [String] The name of the metric to rank by, if rankBy is 'metric'.
@@ -57,7 +59,8 @@ class LeaderboardsAllResponseItem
5759
# @param name [String] The user-facing name of the leaderboard.
5860
# @param key [String] The unique key used to reference the leaderboard in APIs.
5961
# @param rank_by [TrophyApiClient::LeaderboardResponseRankBy] What the leaderboard ranks by.
60-
# @param breakdown_attribute [String] The key of the attribute to break down this leaderboard by.
62+
# @param breakdown_attribute [String] Deprecated. The key of the attribute to break down this leaderboard by.
63+
# @param breakdown_attributes [Array<String>] The user attribute keys that this leaderboard is broken down by.
6164
# @param metric_key [String] The key of the metric to rank by, if rankBy is 'metric'.
6265
# @param metric_name [String] The name of the metric to rank by, if rankBy is 'metric'.
6366
# @param points_system_key [String] The key of the points system to rank by, if rankBy is 'points'.
@@ -73,14 +76,15 @@ class LeaderboardsAllResponseItem
7376
# type. Null for one-time leaderboards.
7477
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
7578
# @return [TrophyApiClient::Leaderboards::LeaderboardsAllResponseItem]
76-
def initialize(status:, id:, name:, key:, rank_by:, start:, max_participants:, breakdown_attribute: OMIT, metric_key: OMIT,
77-
metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, description: OMIT, end_: OMIT, run_unit: OMIT, run_interval: OMIT, additional_properties: nil)
79+
def initialize(status:, id:, name:, key:, rank_by:, breakdown_attributes:, start:, max_participants:, breakdown_attribute: OMIT,
80+
metric_key: OMIT, metric_name: OMIT, points_system_key: OMIT, points_system_name: OMIT, description: OMIT, end_: OMIT, run_unit: OMIT, run_interval: OMIT, additional_properties: nil)
7881
@status = status
7982
@id = id
8083
@name = name
8184
@key = key
8285
@rank_by = rank_by
8386
@breakdown_attribute = breakdown_attribute if breakdown_attribute != OMIT
87+
@breakdown_attributes = breakdown_attributes
8488
@metric_key = metric_key if metric_key != OMIT
8589
@metric_name = metric_name if metric_name != OMIT
8690
@points_system_key = points_system_key if points_system_key != OMIT
@@ -99,6 +103,7 @@ def initialize(status:, id:, name:, key:, rank_by:, start:, max_participants:, b
99103
"key": key,
100104
"rankBy": rank_by,
101105
"breakdownAttribute": breakdown_attribute,
106+
"breakdownAttributes": breakdown_attributes,
102107
"metricKey": metric_key,
103108
"metricName": metric_name,
104109
"pointsSystemKey": points_system_key,
@@ -127,6 +132,7 @@ def self.from_json(json_object:)
127132
key = parsed_json["key"]
128133
rank_by = parsed_json["rankBy"]
129134
breakdown_attribute = parsed_json["breakdownAttribute"]
135+
breakdown_attributes = parsed_json["breakdownAttributes"]
130136
metric_key = parsed_json["metricKey"]
131137
metric_name = parsed_json["metricName"]
132138
points_system_key = parsed_json["pointsSystemKey"]
@@ -144,6 +150,7 @@ def self.from_json(json_object:)
144150
key: key,
145151
rank_by: rank_by,
146152
breakdown_attribute: breakdown_attribute,
153+
breakdown_attributes: breakdown_attributes,
147154
metric_key: metric_key,
148155
metric_name: metric_name,
149156
points_system_key: points_system_key,
@@ -178,6 +185,7 @@ def self.validate_raw(obj:)
178185
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
179186
obj.rank_by.is_a?(TrophyApiClient::LeaderboardResponseRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
180187
obj.breakdown_attribute&.is_a?(String) != false || raise("Passed value for field obj.breakdown_attribute is not the expected type, validation failed.")
188+
obj.breakdown_attributes.is_a?(Array) != false || raise("Passed value for field obj.breakdown_attributes is not the expected type, validation failed.")
181189
obj.metric_key&.is_a?(String) != false || raise("Passed value for field obj.metric_key is not the expected type, validation failed.")
182190
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
183191
obj.points_system_key&.is_a?(String) != false || raise("Passed value for field obj.points_system_key is not the expected type, validation failed.")

lib/trophy_api_client/types/achievement_response.rb

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require_relative "achievement_response_trigger"
44
require_relative "achievement_response_user_attributes_item"
55
require_relative "achievement_response_event_attribute"
6+
require_relative "achievement_response_event_attributes_item"
67
require "ostruct"
78
require "json"
89

@@ -37,11 +38,13 @@ class AchievementResponse
3738
# trigger = 'metric')
3839
attr_reader :metric_name
3940
# @return [Array<TrophyApiClient::AchievementResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
40-
# Only present if the achievement has user attribute filters configured.
4141
attr_reader :user_attributes
42-
# @return [TrophyApiClient::AchievementResponseEventAttribute] Event attribute filter that must be met for this achievement to be completed.
43-
# Only present if the achievement has an event filter configured.
42+
# @return [TrophyApiClient::AchievementResponseEventAttribute] Deprecated. Event attribute filter that must be met for this achievement to be
43+
# completed. Only present if the achievement has an event filter configured.
4444
attr_reader :event_attribute
45+
# @return [Array<TrophyApiClient::AchievementResponseEventAttributesItem>] Event attribute filters that must be met for this achievement to be completed.
46+
# Omitted for non-metric achievements.
47+
attr_reader :event_attributes
4548
# @return [OpenStruct] Additional properties unmapped to the current class definition
4649
attr_reader :additional_properties
4750
# @return [Object]
@@ -68,13 +71,14 @@ class AchievementResponse
6871
# @param metric_name [String] The name of the metric associated with this achievement (only applicable if
6972
# trigger = 'metric')
7073
# @param user_attributes [Array<TrophyApiClient::AchievementResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
71-
# Only present if the achievement has user attribute filters configured.
72-
# @param event_attribute [TrophyApiClient::AchievementResponseEventAttribute] Event attribute filter that must be met for this achievement to be completed.
73-
# Only present if the achievement has an event filter configured.
74+
# @param event_attribute [TrophyApiClient::AchievementResponseEventAttribute] Deprecated. Event attribute filter that must be met for this achievement to be
75+
# completed. Only present if the achievement has an event filter configured.
76+
# @param event_attributes [Array<TrophyApiClient::AchievementResponseEventAttributesItem>] Event attribute filters that must be met for this achievement to be completed.
77+
# Omitted for non-metric achievements.
7478
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
7579
# @return [TrophyApiClient::AchievementResponse]
76-
def initialize(id:, name:, trigger:, description: OMIT, badge_url: OMIT, key: OMIT, streak_length: OMIT,
77-
achievement_ids: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, user_attributes: OMIT, event_attribute: OMIT, additional_properties: nil)
80+
def initialize(id:, name:, trigger:, user_attributes:, description: OMIT, badge_url: OMIT, key: OMIT, streak_length: OMIT,
81+
achievement_ids: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, event_attribute: OMIT, event_attributes: OMIT, additional_properties: nil)
7882
@id = id
7983
@name = name
8084
@trigger = trigger
@@ -86,8 +90,9 @@ def initialize(id:, name:, trigger:, description: OMIT, badge_url: OMIT, key: OM
8690
@metric_id = metric_id if metric_id != OMIT
8791
@metric_value = metric_value if metric_value != OMIT
8892
@metric_name = metric_name if metric_name != OMIT
89-
@user_attributes = user_attributes if user_attributes != OMIT
93+
@user_attributes = user_attributes
9094
@event_attribute = event_attribute if event_attribute != OMIT
95+
@event_attributes = event_attributes if event_attributes != OMIT
9196
@additional_properties = additional_properties
9297
@_field_set = {
9398
"id": id,
@@ -102,7 +107,8 @@ def initialize(id:, name:, trigger:, description: OMIT, badge_url: OMIT, key: OM
102107
"metricValue": metric_value,
103108
"metricName": metric_name,
104109
"userAttributes": user_attributes,
105-
"eventAttribute": event_attribute
110+
"eventAttribute": event_attribute,
111+
"eventAttributes": event_attributes
106112
}.reject do |_k, v|
107113
v == OMIT
108114
end
@@ -136,6 +142,10 @@ def self.from_json(json_object:)
136142
event_attribute = parsed_json["eventAttribute"].to_json
137143
event_attribute = TrophyApiClient::AchievementResponseEventAttribute.from_json(json_object: event_attribute)
138144
end
145+
event_attributes = parsed_json["eventAttributes"]&.map do |item|
146+
item = item.to_json
147+
TrophyApiClient::AchievementResponseEventAttributesItem.from_json(json_object: item)
148+
end
139149
new(
140150
id: id,
141151
name: name,
@@ -150,6 +160,7 @@ def self.from_json(json_object:)
150160
metric_name: metric_name,
151161
user_attributes: user_attributes,
152162
event_attribute: event_attribute,
163+
event_attributes: event_attributes,
153164
additional_properties: struct
154165
)
155166
end
@@ -179,8 +190,9 @@ def self.validate_raw(obj:)
179190
obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
180191
obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
181192
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
182-
obj.user_attributes&.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.")
193+
obj.user_attributes.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.")
183194
obj.event_attribute.nil? || TrophyApiClient::AchievementResponseEventAttribute.validate_raw(obj: obj.event_attribute)
195+
obj.event_attributes&.is_a?(Array) != false || raise("Passed value for field obj.event_attributes is not the expected type, validation failed.")
184196
end
185197
end
186198
end

lib/trophy_api_client/types/achievement_response_event_attribute.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
require "json"
55

66
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.
7+
# Deprecated. Event attribute filter that must be met for this achievement to be
8+
# completed. Only present if the achievement has an event filter configured.
99
class AchievementResponseEventAttribute
1010
# @return [String] The key of the event attribute.
1111
attr_reader :key
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# frozen_string_literal: true
2+
3+
require "ostruct"
4+
require "json"
5+
6+
module TrophyApiClient
7+
class AchievementResponseEventAttributesItem
8+
# @return [String] The key of the event attribute.
9+
attr_reader :key
10+
# @return [String] The value of the event 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 event attribute.
21+
# @param value [String] The value of the event attribute.
22+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
23+
# @return [TrophyApiClient::AchievementResponseEventAttributesItem]
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+
# AchievementResponseEventAttributesItem
33+
#
34+
# @param json_object [String]
35+
# @return [TrophyApiClient::AchievementResponseEventAttributesItem]
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 AchievementResponseEventAttributesItem 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.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
63+
obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
64+
end
65+
end
66+
end

0 commit comments

Comments
 (0)