Skip to content

Commit 1ea93f4

Browse files
Automatically update Ruby SDK
1 parent a887117 commit 1ea93f4

23 files changed

+294
-232
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.0.38"
5+
VERSION = "1.0.40-beta.5"
66
AUTHORS = ["Trophy Labs, Inc"].freeze
77
EMAIL = ""
88
SUMMARY = "Ruby library for the Trophy API."

lib/trophy_api_client/admin/streaks/client.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
require_relative "../../../requests"
4+
require_relative "types/restore_streaks_request_users_item"
45
require_relative "../../types/restore_streaks_response"
56
require "async"
67

@@ -20,7 +21,8 @@ def initialize(request_client:)
2021
# the case of daily streaks), one year (in the case of weekly streaks), or two
2122
# years (in the case of monthly streaks).
2223
#
23-
# @param user_ids [Array<String>] Array of user IDs to restore streaks for. Maximum 100 users per request.
24+
# @param users [Array<Hash>] Array of users to restore streaks for. Maximum 100 users per request.Request of type Array<TrophyApiClient::Admin::Streaks::RestoreStreaksRequestUsersItem>, as a Hash
25+
# * :id (String)
2426
# @param request_options [TrophyApiClient::RequestOptions]
2527
# @return [TrophyApiClient::RestoreStreaksResponse]
2628
# @example
@@ -29,8 +31,8 @@ def initialize(request_client:)
2931
# environment: TrophyApiClient::Environment::PRODUCTION,
3032
# api_key: "YOUR_API_KEY"
3133
# )
32-
# api.admin.streaks.restore(user_ids: ["user-123", "user-456"])
33-
def restore(user_ids:, request_options: nil)
34+
# api.admin.streaks.restore(users: [{ id: "user-123" }, { id: "user-456" }])
35+
def restore(users:, request_options: nil)
3436
response = @request_client.conn.post do |req|
3537
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
3638
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
@@ -42,7 +44,7 @@ def restore(user_ids:, request_options: nil)
4244
unless request_options.nil? || request_options&.additional_query_parameters.nil?
4345
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
4446
end
45-
req.body = { **(request_options&.additional_body_parameters || {}), userIds: user_ids }.compact
47+
req.body = { **(request_options&.additional_body_parameters || {}), users: users }.compact
4648
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/streaks/restore"
4749
end
4850
TrophyApiClient::RestoreStreaksResponse.from_json(json_object: response.body)
@@ -63,7 +65,8 @@ def initialize(request_client:)
6365
# the case of daily streaks), one year (in the case of weekly streaks), or two
6466
# years (in the case of monthly streaks).
6567
#
66-
# @param user_ids [Array<String>] Array of user IDs to restore streaks for. Maximum 100 users per request.
68+
# @param users [Array<Hash>] Array of users to restore streaks for. Maximum 100 users per request.Request of type Array<TrophyApiClient::Admin::Streaks::RestoreStreaksRequestUsersItem>, as a Hash
69+
# * :id (String)
6770
# @param request_options [TrophyApiClient::RequestOptions]
6871
# @return [TrophyApiClient::RestoreStreaksResponse]
6972
# @example
@@ -72,8 +75,8 @@ def initialize(request_client:)
7275
# environment: TrophyApiClient::Environment::PRODUCTION,
7376
# api_key: "YOUR_API_KEY"
7477
# )
75-
# api.admin.streaks.restore(user_ids: ["user-123", "user-456"])
76-
def restore(user_ids:, request_options: nil)
78+
# api.admin.streaks.restore(users: [{ id: "user-123" }, { id: "user-456" }])
79+
def restore(users:, request_options: nil)
7780
Async do
7881
response = @request_client.conn.post do |req|
7982
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
@@ -86,7 +89,7 @@ def restore(user_ids:, request_options: nil)
8689
unless request_options.nil? || request_options&.additional_query_parameters.nil?
8790
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
8891
end
89-
req.body = { **(request_options&.additional_body_parameters || {}), userIds: user_ids }.compact
92+
req.body = { **(request_options&.additional_body_parameters || {}), users: users }.compact
9093
req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/streaks/restore"
9194
end
9295
TrophyApiClient::RestoreStreaksResponse.from_json(json_object: response.body)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# frozen_string_literal: true
2+
3+
require "ostruct"
4+
require "json"
5+
6+
module TrophyApiClient
7+
module Admin
8+
class Streaks
9+
class RestoreStreaksRequestUsersItem
10+
# @return [String] The ID of the user to restore streaks for.
11+
attr_reader :id
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 id [String] The ID of the user to restore streaks for.
21+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
22+
# @return [TrophyApiClient::Admin::Streaks::RestoreStreaksRequestUsersItem]
23+
def initialize(id:, additional_properties: nil)
24+
@id = id
25+
@additional_properties = additional_properties
26+
@_field_set = { "id": id }
27+
end
28+
29+
# Deserialize a JSON object to an instance of RestoreStreaksRequestUsersItem
30+
#
31+
# @param json_object [String]
32+
# @return [TrophyApiClient::Admin::Streaks::RestoreStreaksRequestUsersItem]
33+
def self.from_json(json_object:)
34+
struct = JSON.parse(json_object, object_class: OpenStruct)
35+
parsed_json = JSON.parse(json_object)
36+
id = parsed_json["id"]
37+
new(id: id, additional_properties: struct)
38+
end
39+
40+
# Serialize an instance of RestoreStreaksRequestUsersItem to a JSON object
41+
#
42+
# @return [String]
43+
def to_json(*_args)
44+
@_field_set&.to_json
45+
end
46+
47+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
48+
# hash and check each fields type against the current object's property
49+
# definitions.
50+
#
51+
# @param obj [Object]
52+
# @return [Void]
53+
def self.validate_raw(obj:)
54+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
55+
end
56+
end
57+
end
58+
end
59+
end

lib/trophy_api_client/types/achievement_completion_response.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# frozen_string_literal: true
22

3-
require_relative "achievement_completion_response_achievement"
3+
require_relative "user_achievement_response"
44
require "ostruct"
55
require "json"
66

77
module TrophyApiClient
88
class AchievementCompletionResponse
99
# @return [String] The unique ID of the completion.
1010
attr_reader :completion_id
11-
# @return [TrophyApiClient::AchievementCompletionResponseAchievement]
11+
# @return [TrophyApiClient::UserAchievementResponse]
1212
attr_reader :achievement
1313
# @return [Hash{String => TrophyApiClient::MetricEventPointsResponse}] A map of points systems by key that were affected by this achievement
1414
# completion.
@@ -22,7 +22,7 @@ class AchievementCompletionResponse
2222
OMIT = Object.new
2323

2424
# @param completion_id [String] The unique ID of the completion.
25-
# @param achievement [TrophyApiClient::AchievementCompletionResponseAchievement]
25+
# @param achievement [TrophyApiClient::UserAchievementResponse]
2626
# @param points [Hash{String => TrophyApiClient::MetricEventPointsResponse}] A map of points systems by key that were affected by this achievement
2727
# completion.
2828
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
@@ -47,7 +47,7 @@ def self.from_json(json_object:)
4747
achievement = nil
4848
else
4949
achievement = parsed_json["achievement"].to_json
50-
achievement = TrophyApiClient::AchievementCompletionResponseAchievement.from_json(json_object: achievement)
50+
achievement = TrophyApiClient::UserAchievementResponse.from_json(json_object: achievement)
5151
end
5252
points = parsed_json["points"]&.transform_values do |value|
5353
value = value.to_json
@@ -76,7 +76,7 @@ def to_json(*_args)
7676
# @return [Void]
7777
def self.validate_raw(obj:)
7878
obj.completion_id.is_a?(String) != false || raise("Passed value for field obj.completion_id is not the expected type, validation failed.")
79-
TrophyApiClient::AchievementCompletionResponseAchievement.validate_raw(obj: obj.achievement)
79+
TrophyApiClient::UserAchievementResponse.validate_raw(obj: obj.achievement)
8080
obj.points.is_a?(Hash) != false || raise("Passed value for field obj.points is not the expected type, validation failed.")
8181
end
8282
end

lib/trophy_api_client/types/achievement_response.rb

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# frozen_string_literal: true
22

33
require_relative "achievement_response_trigger"
4+
require_relative "achievement_response_user_attributes_item"
5+
require_relative "achievement_response_event_attribute"
46
require "ostruct"
57
require "json"
68

@@ -31,6 +33,12 @@ class AchievementResponse
3133
# @return [String] The name of the metric associated with this achievement (only applicable if
3234
# trigger = 'metric')
3335
attr_reader :metric_name
36+
# @return [Array<TrophyApiClient::AchievementResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
37+
# Only present if the achievement has user attribute filters configured.
38+
attr_reader :user_attributes
39+
# @return [TrophyApiClient::AchievementResponseEventAttribute] Event attribute filter that must be met for this achievement to be completed.
40+
# Only present if the achievement has an event filter configured.
41+
attr_reader :event_attribute
3442
# @return [OpenStruct] Additional properties unmapped to the current class definition
3543
attr_reader :additional_properties
3644
# @return [Object]
@@ -54,20 +62,26 @@ class AchievementResponse
5462
# trigger = 'metric')
5563
# @param metric_name [String] The name of the metric associated with this achievement (only applicable if
5664
# trigger = 'metric')
65+
# @param user_attributes [Array<TrophyApiClient::AchievementResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
66+
# Only present if the achievement has user attribute filters configured.
67+
# @param event_attribute [TrophyApiClient::AchievementResponseEventAttribute] Event attribute filter that must be met for this achievement to be completed.
68+
# Only present if the achievement has an event filter configured.
5769
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
5870
# @return [TrophyApiClient::AchievementResponse]
59-
def initialize(id:, name:, trigger:, key:, description: OMIT, badge_url: OMIT, streak_length: OMIT,
60-
metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, additional_properties: nil)
71+
def initialize(id:, name:, trigger:, description: OMIT, badge_url: OMIT, key: OMIT, streak_length: OMIT,
72+
metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, user_attributes: OMIT, event_attribute: OMIT, additional_properties: nil)
6173
@id = id
6274
@name = name
6375
@trigger = trigger
6476
@description = description if description != OMIT
6577
@badge_url = badge_url if badge_url != OMIT
66-
@key = key
78+
@key = key if key != OMIT
6779
@streak_length = streak_length if streak_length != OMIT
6880
@metric_id = metric_id if metric_id != OMIT
6981
@metric_value = metric_value if metric_value != OMIT
7082
@metric_name = metric_name if metric_name != OMIT
83+
@user_attributes = user_attributes if user_attributes != OMIT
84+
@event_attribute = event_attribute if event_attribute != OMIT
7185
@additional_properties = additional_properties
7286
@_field_set = {
7387
"id": id,
@@ -79,7 +93,9 @@ def initialize(id:, name:, trigger:, key:, description: OMIT, badge_url: OMIT, s
7993
"streakLength": streak_length,
8094
"metricId": metric_id,
8195
"metricValue": metric_value,
82-
"metricName": metric_name
96+
"metricName": metric_name,
97+
"userAttributes": user_attributes,
98+
"eventAttribute": event_attribute
8399
}.reject do |_k, v|
84100
v == OMIT
85101
end
@@ -102,6 +118,16 @@ def self.from_json(json_object:)
102118
metric_id = parsed_json["metricId"]
103119
metric_value = parsed_json["metricValue"]
104120
metric_name = parsed_json["metricName"]
121+
user_attributes = parsed_json["userAttributes"]&.map do |item|
122+
item = item.to_json
123+
TrophyApiClient::AchievementResponseUserAttributesItem.from_json(json_object: item)
124+
end
125+
if parsed_json["eventAttribute"].nil?
126+
event_attribute = nil
127+
else
128+
event_attribute = parsed_json["eventAttribute"].to_json
129+
event_attribute = TrophyApiClient::AchievementResponseEventAttribute.from_json(json_object: event_attribute)
130+
end
105131
new(
106132
id: id,
107133
name: name,
@@ -113,6 +139,8 @@ def self.from_json(json_object:)
113139
metric_id: metric_id,
114140
metric_value: metric_value,
115141
metric_name: metric_name,
142+
user_attributes: user_attributes,
143+
event_attribute: event_attribute,
116144
additional_properties: struct
117145
)
118146
end
@@ -136,11 +164,13 @@ def self.validate_raw(obj:)
136164
obj.trigger.is_a?(TrophyApiClient::AchievementResponseTrigger) != false || raise("Passed value for field obj.trigger is not the expected type, validation failed.")
137165
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
138166
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
139-
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
167+
obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
140168
obj.streak_length&.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.")
141169
obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
142170
obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
143171
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
172+
obj.user_attributes&.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.")
173+
obj.event_attribute.nil? || TrophyApiClient::AchievementResponseEventAttribute.validate_raw(obj: obj.event_attribute)
144174
end
145175
end
146176
end

lib/trophy_api_client/types/achievement_with_stats_response_event_attribute.rb renamed to lib/trophy_api_client/types/achievement_response_event_attribute.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
module TrophyApiClient
77
# Event attribute filter that must be met for this achievement to be completed.
88
# Only present if the achievement has an event filter configured.
9-
class AchievementWithStatsResponseEventAttribute
9+
class AchievementResponseEventAttribute
1010
# @return [String] The key of the event attribute.
1111
attr_reader :key
1212
# @return [String] The value of the event attribute.
@@ -22,19 +22,18 @@ class AchievementWithStatsResponseEventAttribute
2222
# @param key [String] The key of the event attribute.
2323
# @param value [String] The value of the event attribute.
2424
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
25-
# @return [TrophyApiClient::AchievementWithStatsResponseEventAttribute]
25+
# @return [TrophyApiClient::AchievementResponseEventAttribute]
2626
def initialize(key:, value:, additional_properties: nil)
2727
@key = key
2828
@value = value
2929
@additional_properties = additional_properties
3030
@_field_set = { "key": key, "value": value }
3131
end
3232

33-
# Deserialize a JSON object to an instance of
34-
# AchievementWithStatsResponseEventAttribute
33+
# Deserialize a JSON object to an instance of AchievementResponseEventAttribute
3534
#
3635
# @param json_object [String]
37-
# @return [TrophyApiClient::AchievementWithStatsResponseEventAttribute]
36+
# @return [TrophyApiClient::AchievementResponseEventAttribute]
3837
def self.from_json(json_object:)
3938
struct = JSON.parse(json_object, object_class: OpenStruct)
4039
parsed_json = JSON.parse(json_object)
@@ -47,8 +46,7 @@ def self.from_json(json_object:)
4746
)
4847
end
4948

50-
# Serialize an instance of AchievementWithStatsResponseEventAttribute to a JSON
51-
# object
49+
# Serialize an instance of AchievementResponseEventAttribute to a JSON object
5250
#
5351
# @return [String]
5452
def to_json(*_args)

lib/trophy_api_client/types/achievement_with_stats_response_user_attributes_item.rb renamed to lib/trophy_api_client/types/achievement_response_user_attributes_item.rb

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

66
module TrophyApiClient
7-
class AchievementWithStatsResponseUserAttributesItem
7+
class AchievementResponseUserAttributesItem
88
# @return [String] The key of the user attribute.
99
attr_reader :key
1010
# @return [String] The value of the user attribute.
@@ -20,7 +20,7 @@ class AchievementWithStatsResponseUserAttributesItem
2020
# @param key [String] The key of the user attribute.
2121
# @param value [String] The value of the user attribute.
2222
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
23-
# @return [TrophyApiClient::AchievementWithStatsResponseUserAttributesItem]
23+
# @return [TrophyApiClient::AchievementResponseUserAttributesItem]
2424
def initialize(key:, value:, additional_properties: nil)
2525
@key = key
2626
@value = value
@@ -29,10 +29,10 @@ def initialize(key:, value:, additional_properties: nil)
2929
end
3030

3131
# Deserialize a JSON object to an instance of
32-
# AchievementWithStatsResponseUserAttributesItem
32+
# AchievementResponseUserAttributesItem
3333
#
3434
# @param json_object [String]
35-
# @return [TrophyApiClient::AchievementWithStatsResponseUserAttributesItem]
35+
# @return [TrophyApiClient::AchievementResponseUserAttributesItem]
3636
def self.from_json(json_object:)
3737
struct = JSON.parse(json_object, object_class: OpenStruct)
3838
parsed_json = JSON.parse(json_object)
@@ -45,8 +45,7 @@ def self.from_json(json_object:)
4545
)
4646
end
4747

48-
# Serialize an instance of AchievementWithStatsResponseUserAttributesItem to a
49-
# JSON object
48+
# Serialize an instance of AchievementResponseUserAttributesItem to a JSON object
5049
#
5150
# @return [String]
5251
def to_json(*_args)

0 commit comments

Comments
 (0)