Skip to content

Commit 288e771

Browse files
Automatically update Ruby SDK
1 parent 8d68ef8 commit 288e771

9 files changed

Lines changed: 87 additions & 87 deletions

File tree

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

lib/trophy_api_client/achievements/client.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def all(user_attributes: nil, request_options: nil)
7676
# environment: TrophyApiClient::Environment::PRODUCTION,
7777
# api_key: "YOUR_API_KEY"
7878
# )
79-
# api.achievements.complete(key: "finish-onboarding", user: { email: "user@example.com", name: "User", tz: "Europe/London", device_tokens: ["token1", "token2"], subscribe_to_emails: true, attributes: { "department": "engineering", "role": "developer" }, id: "user-id" })
79+
# api.achievements.complete(key: "finish-onboarding", user: { email: "user@example.com", tz: "Europe/London", id: "user-id" })
8080
def complete(key:, user:, request_options: nil)
8181
response = @request_client.conn.post do |req|
8282
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
@@ -167,7 +167,7 @@ def all(user_attributes: nil, request_options: nil)
167167
# environment: TrophyApiClient::Environment::PRODUCTION,
168168
# api_key: "YOUR_API_KEY"
169169
# )
170-
# api.achievements.complete(key: "finish-onboarding", user: { email: "user@example.com", name: "User", tz: "Europe/London", device_tokens: ["token1", "token2"], subscribe_to_emails: true, attributes: { "department": "engineering", "role": "developer" }, id: "user-id" })
170+
# api.achievements.complete(key: "finish-onboarding", user: { email: "user@example.com", tz: "Europe/London", id: "user-id" })
171171
def complete(key:, user:, request_options: nil)
172172
Async do
173173
response = @request_client.conn.post do |req|

lib/trophy_api_client/leaderboards/client.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,15 @@ def all(request_options: nil)
5656
#
5757
# @param key [String] Unique key of the leaderboard as set when created.
5858
# @param offset [Integer] Number of rankings to skip for pagination.
59-
# @param limit [Integer] Maximum number of rankings to return.
59+
# @param limit [Integer] Maximum number of rankings to return. Cannot be greater than the size of the
60+
# leaderboard.
6061
# @param run [String] Specific run date in YYYY-MM-DD format. If not provided, returns the current
6162
# run.
6263
# @param user_id [String] When provided, offset is relative to this user's position on the leaderboard. If
6364
# the user is not found in the leaderboard, returns empty rankings array.
64-
# @param user_attributes [String] Attribute key and value to filter the rankings by, separated by a colon. This
65-
# parameter is required, and only valid for leaderboards with a breakdown
66-
# attribute.
65+
# @param user_attributes [String] Attribute key and value to filter the rankings by, separated by a colon. For
66+
# example, `city:London`. This parameter is required, and only valid for
67+
# leaderboards with a breakdown attribute.
6768
# @param request_options [TrophyApiClient::RequestOptions]
6869
# @return [TrophyApiClient::LeaderboardResponseWithRankings]
6970
# @example
@@ -157,14 +158,15 @@ def all(request_options: nil)
157158
#
158159
# @param key [String] Unique key of the leaderboard as set when created.
159160
# @param offset [Integer] Number of rankings to skip for pagination.
160-
# @param limit [Integer] Maximum number of rankings to return.
161+
# @param limit [Integer] Maximum number of rankings to return. Cannot be greater than the size of the
162+
# leaderboard.
161163
# @param run [String] Specific run date in YYYY-MM-DD format. If not provided, returns the current
162164
# run.
163165
# @param user_id [String] When provided, offset is relative to this user's position on the leaderboard. If
164166
# the user is not found in the leaderboard, returns empty rankings array.
165-
# @param user_attributes [String] Attribute key and value to filter the rankings by, separated by a colon. This
166-
# parameter is required, and only valid for leaderboards with a breakdown
167-
# attribute.
167+
# @param user_attributes [String] Attribute key and value to filter the rankings by, separated by a colon. For
168+
# example, `city:London`. This parameter is required, and only valid for
169+
# leaderboards with a breakdown attribute.
168170
# @param request_options [TrophyApiClient::RequestOptions]
169171
# @return [TrophyApiClient::LeaderboardResponseWithRankings]
170172
# @example

lib/trophy_api_client/metrics/client.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def initialize(request_client:)
4242
# api.metrics.event(
4343
# idempotency_key: "e4296e4b-8493-4bd1-9c30-5a1a9ac4d78f",
4444
# key: "words-written",
45-
# user: { email: "user@example.com", name: "User", tz: "Europe/London", device_tokens: ["token1", "token2"], subscribe_to_emails: true, attributes: { "department": "engineering", "role": "developer" }, id: "18" },
45+
# user: { email: "user@example.com", tz: "Europe/London", attributes: { "department": "engineering", "role": "developer" }, id: "18" },
4646
# value: 750,
4747
# attributes: { "category": "writing", "source": "mobile-app" }
4848
# )
@@ -107,7 +107,7 @@ def initialize(request_client:)
107107
# api.metrics.event(
108108
# idempotency_key: "e4296e4b-8493-4bd1-9c30-5a1a9ac4d78f",
109109
# key: "words-written",
110-
# user: { email: "user@example.com", name: "User", tz: "Europe/London", device_tokens: ["token1", "token2"], subscribe_to_emails: true, attributes: { "department": "engineering", "role": "developer" }, id: "18" },
110+
# user: { email: "user@example.com", tz: "Europe/London", attributes: { "department": "engineering", "role": "developer" }, id: "18" },
111111
# value: 750,
112112
# attributes: { "category": "writing", "source": "mobile-app" }
113113
# )

lib/trophy_api_client/types/updated_user.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ class UpdatedUser
3838
# up in the Trophy dashboard.
3939
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
4040
# @return [TrophyApiClient::UpdatedUser]
41-
def initialize(email:, name:, device_tokens:, subscribe_to_emails:, attributes:, tz: OMIT,
41+
def initialize(email: OMIT, name: OMIT, tz: OMIT, device_tokens: OMIT, subscribe_to_emails: OMIT, attributes: OMIT,
4242
additional_properties: nil)
43-
@email = email
44-
@name = name
43+
@email = email if email != OMIT
44+
@name = name if name != OMIT
4545
@tz = tz if tz != OMIT
46-
@device_tokens = device_tokens
47-
@subscribe_to_emails = subscribe_to_emails
48-
@attributes = attributes
46+
@device_tokens = device_tokens if device_tokens != OMIT
47+
@subscribe_to_emails = subscribe_to_emails if subscribe_to_emails != OMIT
48+
@attributes = attributes if attributes != OMIT
4949
@additional_properties = additional_properties
5050
@_field_set = {
5151
"email": email,
@@ -97,12 +97,12 @@ def to_json(*_args)
9797
# @param obj [Object]
9898
# @return [Void]
9999
def self.validate_raw(obj:)
100-
obj.email.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.")
101-
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
100+
obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.")
101+
obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
102102
obj.tz&.is_a?(String) != false || raise("Passed value for field obj.tz is not the expected type, validation failed.")
103-
obj.device_tokens.is_a?(Array) != false || raise("Passed value for field obj.device_tokens is not the expected type, validation failed.")
104-
obj.subscribe_to_emails.is_a?(Boolean) != false || raise("Passed value for field obj.subscribe_to_emails is not the expected type, validation failed.")
105-
obj.attributes.is_a?(Hash) != false || raise("Passed value for field obj.attributes is not the expected type, validation failed.")
103+
obj.device_tokens&.is_a?(Array) != false || raise("Passed value for field obj.device_tokens is not the expected type, validation failed.")
104+
obj.subscribe_to_emails&.is_a?(Boolean) != false || raise("Passed value for field obj.subscribe_to_emails is not the expected type, validation failed.")
105+
obj.attributes&.is_a?(Hash) != false || raise("Passed value for field obj.attributes is not the expected type, validation failed.")
106106
end
107107
end
108108
end

lib/trophy_api_client/types/upserted_user.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ class UpsertedUser
4141
# up in the Trophy dashboard.
4242
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
4343
# @return [TrophyApiClient::UpsertedUser]
44-
def initialize(id:, email:, name:, device_tokens:, subscribe_to_emails:, attributes:, tz: OMIT,
45-
additional_properties: nil)
44+
def initialize(id:, email: OMIT, name: OMIT, tz: OMIT, device_tokens: OMIT, subscribe_to_emails: OMIT,
45+
attributes: OMIT, additional_properties: nil)
4646
@id = id
47-
@email = email
48-
@name = name
47+
@email = email if email != OMIT
48+
@name = name if name != OMIT
4949
@tz = tz if tz != OMIT
50-
@device_tokens = device_tokens
51-
@subscribe_to_emails = subscribe_to_emails
52-
@attributes = attributes
50+
@device_tokens = device_tokens if device_tokens != OMIT
51+
@subscribe_to_emails = subscribe_to_emails if subscribe_to_emails != OMIT
52+
@attributes = attributes if attributes != OMIT
5353
@additional_properties = additional_properties
5454
@_field_set = {
5555
"id": id,
@@ -105,12 +105,12 @@ def to_json(*_args)
105105
# @return [Void]
106106
def self.validate_raw(obj:)
107107
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
108-
obj.email.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.")
109-
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
108+
obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.")
109+
obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
110110
obj.tz&.is_a?(String) != false || raise("Passed value for field obj.tz is not the expected type, validation failed.")
111-
obj.device_tokens.is_a?(Array) != false || raise("Passed value for field obj.device_tokens is not the expected type, validation failed.")
112-
obj.subscribe_to_emails.is_a?(Boolean) != false || raise("Passed value for field obj.subscribe_to_emails is not the expected type, validation failed.")
113-
obj.attributes.is_a?(Hash) != false || raise("Passed value for field obj.attributes is not the expected type, validation failed.")
111+
obj.device_tokens&.is_a?(Array) != false || raise("Passed value for field obj.device_tokens is not the expected type, validation failed.")
112+
obj.subscribe_to_emails&.is_a?(Boolean) != false || raise("Passed value for field obj.subscribe_to_emails is not the expected type, validation failed.")
113+
obj.attributes&.is_a?(Hash) != false || raise("Passed value for field obj.attributes is not the expected type, validation failed.")
114114
end
115115
end
116116
end

lib/trophy_api_client/types/user.rb

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,28 @@
77
module TrophyApiClient
88
# A user of your application.
99
class User
10-
# @return [Boolean] Whether the user is in the control group, meaning they do not receive emails or
11-
# other communications from Trophy.
12-
attr_reader :control
13-
# @return [DateTime] The date and time the user was created, in ISO 8601 format.
14-
attr_reader :created
15-
# @return [DateTime] The date and time the user was last updated, in ISO 8601 format.
16-
attr_reader :updated
1710
# @return [String] The ID of the user in your database. Must be a string.
1811
attr_reader :id
19-
# @return [String] The user's email address. Required if subscribeToEmails is true.
12+
# @return [String] The user's email address.
2013
attr_reader :email
21-
# @return [String] The name to refer to the user by in emails.
14+
# @return [String] The name of the user.
2215
attr_reader :name
23-
# @return [String] The user's timezone (used for email scheduling).
16+
# @return [String] The user's timezone.
2417
attr_reader :tz
25-
# @return [Array<String>] The user's device tokens, used for push notifications.
18+
# @return [Array<String>] The user's device tokens.
2619
attr_reader :device_tokens
27-
# @return [Boolean] Whether the user should receive Trophy-powered emails. If false, Trophy will not
28-
# store the user's email address.
20+
# @return [Boolean] Whether the user is opted into receiving Trophy-powered emails.
2921
attr_reader :subscribe_to_emails
3022
# @return [Hash{String => String}] User attributes as key-value pairs. Keys must match existing user attributes set
3123
# up in the Trophy dashboard.
3224
attr_reader :attributes
25+
# @return [Boolean] Whether the user is in the control group, meaning they do not receive emails or
26+
# other communications from Trophy.
27+
attr_reader :control
28+
# @return [DateTime] The date and time the user was created, in ISO 8601 format.
29+
attr_reader :created
30+
# @return [DateTime] The date and time the user was last updated, in ISO 8601 format.
31+
attr_reader :updated
3332
# @return [OpenStruct] Additional properties unmapped to the current class definition
3433
attr_reader :additional_properties
3534
# @return [Object]
@@ -38,45 +37,44 @@ class User
3837

3938
OMIT = Object.new
4039

40+
# @param id [String] The ID of the user in your database. Must be a string.
41+
# @param email [String] The user's email address.
42+
# @param name [String] The name of the user.
43+
# @param tz [String] The user's timezone.
44+
# @param device_tokens [Array<String>] The user's device tokens.
45+
# @param subscribe_to_emails [Boolean] Whether the user is opted into receiving Trophy-powered emails.
46+
# @param attributes [Hash{String => String}] User attributes as key-value pairs. Keys must match existing user attributes set
47+
# up in the Trophy dashboard.
4148
# @param control [Boolean] Whether the user is in the control group, meaning they do not receive emails or
4249
# other communications from Trophy.
4350
# @param created [DateTime] The date and time the user was created, in ISO 8601 format.
4451
# @param updated [DateTime] The date and time the user was last updated, in ISO 8601 format.
45-
# @param id [String] The ID of the user in your database. Must be a string.
46-
# @param email [String] The user's email address. Required if subscribeToEmails is true.
47-
# @param name [String] The name to refer to the user by in emails.
48-
# @param tz [String] The user's timezone (used for email scheduling).
49-
# @param device_tokens [Array<String>] The user's device tokens, used for push notifications.
50-
# @param subscribe_to_emails [Boolean] Whether the user should receive Trophy-powered emails. If false, Trophy will not
51-
# store the user's email address.
52-
# @param attributes [Hash{String => String}] User attributes as key-value pairs. Keys must match existing user attributes set
53-
# up in the Trophy dashboard.
5452
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
5553
# @return [TrophyApiClient::User]
56-
def initialize(control:, created:, updated:, id:, email:, name:, device_tokens:, subscribe_to_emails:, attributes:,
57-
tz: OMIT, additional_properties: nil)
58-
@control = control
59-
@created = created
60-
@updated = updated
54+
def initialize(id:, device_tokens:, subscribe_to_emails:, attributes:, control:, created:, updated:, email: OMIT,
55+
name: OMIT, tz: OMIT, additional_properties: nil)
6156
@id = id
62-
@email = email
63-
@name = name
57+
@email = email if email != OMIT
58+
@name = name if name != OMIT
6459
@tz = tz if tz != OMIT
6560
@device_tokens = device_tokens
6661
@subscribe_to_emails = subscribe_to_emails
6762
@attributes = attributes
63+
@control = control
64+
@created = created
65+
@updated = updated
6866
@additional_properties = additional_properties
6967
@_field_set = {
70-
"control": control,
71-
"created": created,
72-
"updated": updated,
7368
"id": id,
7469
"email": email,
7570
"name": name,
7671
"tz": tz,
7772
"deviceTokens": device_tokens,
7873
"subscribeToEmails": subscribe_to_emails,
79-
"attributes": attributes
74+
"attributes": attributes,
75+
"control": control,
76+
"created": created,
77+
"updated": updated
8078
}.reject do |_k, v|
8179
v == OMIT
8280
end
@@ -89,27 +87,27 @@ def initialize(control:, created:, updated:, id:, email:, name:, device_tokens:,
8987
def self.from_json(json_object:)
9088
struct = JSON.parse(json_object, object_class: OpenStruct)
9189
parsed_json = JSON.parse(json_object)
92-
control = parsed_json["control"]
93-
created = (DateTime.parse(parsed_json["created"]) unless parsed_json["created"].nil?)
94-
updated = (DateTime.parse(parsed_json["updated"]) unless parsed_json["updated"].nil?)
9590
id = parsed_json["id"]
9691
email = parsed_json["email"]
9792
name = parsed_json["name"]
9893
tz = parsed_json["tz"]
9994
device_tokens = parsed_json["deviceTokens"]
10095
subscribe_to_emails = parsed_json["subscribeToEmails"]
10196
attributes = parsed_json["attributes"]
97+
control = parsed_json["control"]
98+
created = (DateTime.parse(parsed_json["created"]) unless parsed_json["created"].nil?)
99+
updated = (DateTime.parse(parsed_json["updated"]) unless parsed_json["updated"].nil?)
102100
new(
103-
control: control,
104-
created: created,
105-
updated: updated,
106101
id: id,
107102
email: email,
108103
name: name,
109104
tz: tz,
110105
device_tokens: device_tokens,
111106
subscribe_to_emails: subscribe_to_emails,
112107
attributes: attributes,
108+
control: control,
109+
created: created,
110+
updated: updated,
113111
additional_properties: struct
114112
)
115113
end
@@ -128,16 +126,16 @@ def to_json(*_args)
128126
# @param obj [Object]
129127
# @return [Void]
130128
def self.validate_raw(obj:)
131-
obj.control.is_a?(Boolean) != false || raise("Passed value for field obj.control is not the expected type, validation failed.")
132-
obj.created.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
133-
obj.updated.is_a?(DateTime) != false || raise("Passed value for field obj.updated is not the expected type, validation failed.")
134129
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
135-
obj.email.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.")
136-
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
130+
obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.")
131+
obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
137132
obj.tz&.is_a?(String) != false || raise("Passed value for field obj.tz is not the expected type, validation failed.")
138133
obj.device_tokens.is_a?(Array) != false || raise("Passed value for field obj.device_tokens is not the expected type, validation failed.")
139134
obj.subscribe_to_emails.is_a?(Boolean) != false || raise("Passed value for field obj.subscribe_to_emails is not the expected type, validation failed.")
140135
obj.attributes.is_a?(Hash) != false || raise("Passed value for field obj.attributes is not the expected type, validation failed.")
136+
obj.control.is_a?(Boolean) != false || raise("Passed value for field obj.control is not the expected type, validation failed.")
137+
obj.created.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
138+
obj.updated.is_a?(DateTime) != false || raise("Passed value for field obj.updated is not the expected type, validation failed.")
141139
end
142140
end
143141
end

0 commit comments

Comments
 (0)