trophy_api_client 1.0.36 → 1.0.40.pre.beta.5

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.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gemconfig.rb +1 -1
  3. data/lib/trophy_api_client/admin/client.rb +6 -6
  4. data/lib/trophy_api_client/admin/streaks/client.rb +84 -16
  5. data/lib/trophy_api_client/admin/streaks/types/restore_streaks_request_users_item.rb +59 -0
  6. data/lib/trophy_api_client/types/achievement_completion_response.rb +5 -5
  7. data/lib/trophy_api_client/types/achievement_response.rb +35 -5
  8. data/lib/trophy_api_client/types/{achievement_with_stats_response_event_attribute.rb → achievement_response_event_attribute.rb} +5 -7
  9. data/lib/trophy_api_client/types/{achievement_with_stats_response_user_attributes_item.rb → achievement_response_user_attributes_item.rb} +5 -6
  10. data/lib/trophy_api_client/types/achievement_with_stats_response.rb +35 -35
  11. data/lib/trophy_api_client/types/bulk_streak_response_item.rb +10 -6
  12. data/lib/trophy_api_client/types/event_response.rb +4 -4
  13. data/lib/trophy_api_client/types/metric_response.rb +4 -4
  14. data/lib/trophy_api_client/types/restore_streaks_response.rb +70 -0
  15. data/lib/trophy_api_client/types/user.rb +4 -4
  16. data/lib/trophy_api_client/types/{completed_achievement_response.rb → user_achievement_response.rb} +40 -10
  17. data/lib/trophy_api_client/types/{achievement_completion_response_achievement.rb → user_achievement_with_stats_response.rb} +56 -26
  18. data/lib/trophy_api_client/types/webhooks_achievement_completed_payload.rb +5 -5
  19. data/lib/trophy_api_client/types/wrapped_activity.rb +134 -0
  20. data/lib/trophy_api_client/types/wrapped_activity_period.rb +95 -0
  21. data/lib/trophy_api_client/types/wrapped_entire_year.rb +114 -0
  22. data/lib/trophy_api_client/types/wrapped_metric.rb +119 -0
  23. data/lib/trophy_api_client/types/wrapped_metric_by_attribute_value_value.rb +103 -0
  24. data/lib/trophy_api_client/types/wrapped_most_active_day.rb +108 -0
  25. data/lib/trophy_api_client/types/wrapped_most_active_month.rb +108 -0
  26. data/lib/trophy_api_client/types/wrapped_most_active_week.rb +116 -0
  27. data/lib/trophy_api_client/types/wrapped_points.rb +106 -0
  28. data/lib/trophy_api_client/types/wrapped_response.rb +79 -0
  29. data/lib/trophy_api_client/types/wrapped_streak.rb +96 -0
  30. data/lib/trophy_api_client/users/client.rb +72 -5
  31. data/lib/trophy_api_client/version.rb +1 -1
  32. data/lib/types_export.rb +17 -4
  33. metadata +18 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70c39a88f44a9a92618d3953c39a947513d02a2ea0dade3fd4fdbdf9de89ad94
4
- data.tar.gz: 4d36287ce62401dd40657fac67764aff80c9c55315d2d611b832c92df533cdbb
3
+ metadata.gz: 2370ecd85550dfdf075f1458764d0070068fe6757fdfb9057644cc8a891bc7eb
4
+ data.tar.gz: 2c731a0e2da22159f6f5ede24317bf83c0b0ca5d100788da182ad96ad4510530
5
5
  SHA512:
6
- metadata.gz: 137070ab6a7c5517ded89325942d327d876e4129c64dbb4929cbc466f73884bf401afe0ab1b61935cf0e5cbea57d86ebe1488f8f0fb2cf08d813e68aa9ec42ea
7
- data.tar.gz: 6f9417b7950b6d2a8cec35da7a8780ae4ad13a59f17a25eb3af05ffed7a3955a05e42d6b8e3c956ef06b84ef95b9b0843023788f476d5961e209c701a865e187
6
+ metadata.gz: 9c35f9fe859def5b504d1310a8bbdd0efed2c06209ce67bca78d2521f2ce87bc7520547b1295941de48bac8e13c7af88b5d74d9c2d2c228f9f4843d8466e53a6
7
+ data.tar.gz: 8361d138e62c2e8616922287b7d5d2747de2f5163d185a69e6eada3a4b89df57f33c7cd395546b84d80a4de8d9402cb4d8474ab495178dae14887c266f1f9f06
data/lib/gemconfig.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module TrophyApiClient
4
4
  module Gemconfig
5
- VERSION = "1.0.36"
5
+ VERSION = "1.0.40-beta.5"
6
6
  AUTHORS = ["Trophy Labs, Inc"].freeze
7
7
  EMAIL = ""
8
8
  SUMMARY = "Ruby library for the Trophy API."
@@ -6,24 +6,24 @@ require_relative "streaks/client"
6
6
  module TrophyApiClient
7
7
  module Admin
8
8
  class Client
9
- # @return [TrophyApiClient::Admin::Streaks::Client]
10
- attr_reader :admin
9
+ # @return [TrophyApiClient::Admin::StreaksClient]
10
+ attr_reader :streaks
11
11
 
12
12
  # @param request_client [TrophyApiClient::RequestClient]
13
13
  # @return [TrophyApiClient::Admin::Client]
14
14
  def initialize(request_client:)
15
- @admin = TrophyApiClient::Admin::Streaks::Client.new(request_client: request_client)
15
+ @streaks = TrophyApiClient::Admin::StreaksClient.new(request_client: request_client)
16
16
  end
17
17
  end
18
18
 
19
19
  class AsyncClient
20
- # @return [TrophyApiClient::Admin::Streaks::AsyncClient]
21
- attr_reader :admin
20
+ # @return [TrophyApiClient::Admin::AsyncStreaksClient]
21
+ attr_reader :streaks
22
22
 
23
23
  # @param request_client [TrophyApiClient::AsyncRequestClient]
24
24
  # @return [TrophyApiClient::Admin::AsyncClient]
25
25
  def initialize(request_client:)
26
- @admin = TrophyApiClient::Admin::Streaks::AsyncClient.new(request_client: request_client)
26
+ @streaks = TrophyApiClient::Admin::AsyncStreaksClient.new(request_client: request_client)
27
27
  end
28
28
  end
29
29
  end
@@ -1,30 +1,98 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "../../../requests"
4
- require_relative "freezes/client"
4
+ require_relative "types/restore_streaks_request_users_item"
5
+ require_relative "../../types/restore_streaks_response"
6
+ require "async"
5
7
 
6
8
  module TrophyApiClient
7
9
  module Admin
8
- module Streaks
9
- class Client
10
- # @return [TrophyApiClient::Admin::Streaks::FreezesClient]
11
- attr_reader :freezes
10
+ class StreaksClient
11
+ # @return [TrophyApiClient::RequestClient]
12
+ attr_reader :request_client
12
13
 
13
- # @param request_client [TrophyApiClient::RequestClient]
14
- # @return [TrophyApiClient::Admin::Streaks::Client]
15
- def initialize(request_client:)
16
- @freezes = TrophyApiClient::Admin::Streaks::FreezesClient.new(request_client: request_client)
14
+ # @param request_client [TrophyApiClient::RequestClient]
15
+ # @return [TrophyApiClient::Admin::StreaksClient]
16
+ def initialize(request_client:)
17
+ @request_client = request_client
18
+ end
19
+
20
+ # Restore streaks for multiple users to the maximum length in the last 90 days (in
21
+ # the case of daily streaks), one year (in the case of weekly streaks), or two
22
+ # years (in the case of monthly streaks).
23
+ #
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)
26
+ # @param request_options [TrophyApiClient::RequestOptions]
27
+ # @return [TrophyApiClient::RestoreStreaksResponse]
28
+ # @example
29
+ # api = TrophyApiClient::Client.new(
30
+ # base_url: "https://api.example.com",
31
+ # environment: TrophyApiClient::Environment::PRODUCTION,
32
+ # api_key: "YOUR_API_KEY"
33
+ # )
34
+ # api.admin.streaks.restore(users: [{ id: "user-123" }, { id: "user-456" }])
35
+ def restore(users:, request_options: nil)
36
+ response = @request_client.conn.post do |req|
37
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
38
+ req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
39
+ req.headers = {
40
+ **(req.headers || {}),
41
+ **@request_client.get_headers,
42
+ **(request_options&.additional_headers || {})
43
+ }.compact
44
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
45
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
46
+ end
47
+ req.body = { **(request_options&.additional_body_parameters || {}), users: users }.compact
48
+ req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/streaks/restore"
17
49
  end
50
+ TrophyApiClient::RestoreStreaksResponse.from_json(json_object: response.body)
18
51
  end
52
+ end
19
53
 
20
- class AsyncClient
21
- # @return [TrophyApiClient::Admin::Streaks::AsyncFreezesClient]
22
- attr_reader :freezes
54
+ class AsyncStreaksClient
55
+ # @return [TrophyApiClient::AsyncRequestClient]
56
+ attr_reader :request_client
57
+
58
+ # @param request_client [TrophyApiClient::AsyncRequestClient]
59
+ # @return [TrophyApiClient::Admin::AsyncStreaksClient]
60
+ def initialize(request_client:)
61
+ @request_client = request_client
62
+ end
23
63
 
24
- # @param request_client [TrophyApiClient::AsyncRequestClient]
25
- # @return [TrophyApiClient::Admin::Streaks::AsyncClient]
26
- def initialize(request_client:)
27
- @freezes = TrophyApiClient::Admin::Streaks::AsyncFreezesClient.new(request_client: request_client)
64
+ # Restore streaks for multiple users to the maximum length in the last 90 days (in
65
+ # the case of daily streaks), one year (in the case of weekly streaks), or two
66
+ # years (in the case of monthly streaks).
67
+ #
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)
70
+ # @param request_options [TrophyApiClient::RequestOptions]
71
+ # @return [TrophyApiClient::RestoreStreaksResponse]
72
+ # @example
73
+ # api = TrophyApiClient::Client.new(
74
+ # base_url: "https://api.example.com",
75
+ # environment: TrophyApiClient::Environment::PRODUCTION,
76
+ # api_key: "YOUR_API_KEY"
77
+ # )
78
+ # api.admin.streaks.restore(users: [{ id: "user-123" }, { id: "user-456" }])
79
+ def restore(users:, request_options: nil)
80
+ Async do
81
+ response = @request_client.conn.post do |req|
82
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
83
+ req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
84
+ req.headers = {
85
+ **(req.headers || {}),
86
+ **@request_client.get_headers,
87
+ **(request_options&.additional_headers || {})
88
+ }.compact
89
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
90
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
91
+ end
92
+ req.body = { **(request_options&.additional_body_parameters || {}), users: users }.compact
93
+ req.url "#{@request_client.get_url(environment: admin, request_options: request_options)}/streaks/restore"
94
+ end
95
+ TrophyApiClient::RestoreStreaksResponse.from_json(json_object: response.body)
28
96
  end
29
97
  end
30
98
  end
@@ -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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "achievement_completion_response_achievement"
3
+ require_relative "user_achievement_response"
4
4
  require "ostruct"
5
5
  require "json"
6
6
 
@@ -8,7 +8,7 @@ module TrophyApiClient
8
8
  class AchievementCompletionResponse
9
9
  # @return [String] The unique ID of the completion.
10
10
  attr_reader :completion_id
11
- # @return [TrophyApiClient::AchievementCompletionResponseAchievement]
11
+ # @return [TrophyApiClient::UserAchievementResponse]
12
12
  attr_reader :achievement
13
13
  # @return [Hash{String => TrophyApiClient::MetricEventPointsResponse}] A map of points systems by key that were affected by this achievement
14
14
  # completion.
@@ -22,7 +22,7 @@ module TrophyApiClient
22
22
  OMIT = Object.new
23
23
 
24
24
  # @param completion_id [String] The unique ID of the completion.
25
- # @param achievement [TrophyApiClient::AchievementCompletionResponseAchievement]
25
+ # @param achievement [TrophyApiClient::UserAchievementResponse]
26
26
  # @param points [Hash{String => TrophyApiClient::MetricEventPointsResponse}] A map of points systems by key that were affected by this achievement
27
27
  # completion.
28
28
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
@@ -47,7 +47,7 @@ module TrophyApiClient
47
47
  achievement = nil
48
48
  else
49
49
  achievement = parsed_json["achievement"].to_json
50
- achievement = TrophyApiClient::AchievementCompletionResponseAchievement.from_json(json_object: achievement)
50
+ achievement = TrophyApiClient::UserAchievementResponse.from_json(json_object: achievement)
51
51
  end
52
52
  points = parsed_json["points"]&.transform_values do |value|
53
53
  value = value.to_json
@@ -76,7 +76,7 @@ module TrophyApiClient
76
76
  # @return [Void]
77
77
  def self.validate_raw(obj:)
78
78
  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)
80
80
  obj.points.is_a?(Hash) != false || raise("Passed value for field obj.points is not the expected type, validation failed.")
81
81
  end
82
82
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "achievement_response_trigger"
4
+ require_relative "achievement_response_user_attributes_item"
5
+ require_relative "achievement_response_event_attribute"
4
6
  require "ostruct"
5
7
  require "json"
6
8
 
@@ -31,6 +33,12 @@ module TrophyApiClient
31
33
  # @return [String] The name of the metric associated with this achievement (only applicable if
32
34
  # trigger = 'metric')
33
35
  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
34
42
  # @return [OpenStruct] Additional properties unmapped to the current class definition
35
43
  attr_reader :additional_properties
36
44
  # @return [Object]
@@ -54,20 +62,26 @@ module TrophyApiClient
54
62
  # trigger = 'metric')
55
63
  # @param metric_name [String] The name of the metric associated with this achievement (only applicable if
56
64
  # 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.
57
69
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
58
70
  # @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)
61
73
  @id = id
62
74
  @name = name
63
75
  @trigger = trigger
64
76
  @description = description if description != OMIT
65
77
  @badge_url = badge_url if badge_url != OMIT
66
- @key = key
78
+ @key = key if key != OMIT
67
79
  @streak_length = streak_length if streak_length != OMIT
68
80
  @metric_id = metric_id if metric_id != OMIT
69
81
  @metric_value = metric_value if metric_value != OMIT
70
82
  @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
71
85
  @additional_properties = additional_properties
72
86
  @_field_set = {
73
87
  "id": id,
@@ -79,7 +93,9 @@ module TrophyApiClient
79
93
  "streakLength": streak_length,
80
94
  "metricId": metric_id,
81
95
  "metricValue": metric_value,
82
- "metricName": metric_name
96
+ "metricName": metric_name,
97
+ "userAttributes": user_attributes,
98
+ "eventAttribute": event_attribute
83
99
  }.reject do |_k, v|
84
100
  v == OMIT
85
101
  end
@@ -102,6 +118,16 @@ module TrophyApiClient
102
118
  metric_id = parsed_json["metricId"]
103
119
  metric_value = parsed_json["metricValue"]
104
120
  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
105
131
  new(
106
132
  id: id,
107
133
  name: name,
@@ -113,6 +139,8 @@ module TrophyApiClient
113
139
  metric_id: metric_id,
114
140
  metric_value: metric_value,
115
141
  metric_name: metric_name,
142
+ user_attributes: user_attributes,
143
+ event_attribute: event_attribute,
116
144
  additional_properties: struct
117
145
  )
118
146
  end
@@ -136,11 +164,13 @@ module TrophyApiClient
136
164
  obj.trigger.is_a?(TrophyApiClient::AchievementResponseTrigger) != false || raise("Passed value for field obj.trigger is not the expected type, validation failed.")
137
165
  obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
138
166
  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.")
140
168
  obj.streak_length&.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.")
141
169
  obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
142
170
  obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
143
171
  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)
144
174
  end
145
175
  end
146
176
  end
@@ -6,7 +6,7 @@ require "json"
6
6
  module TrophyApiClient
7
7
  # Event attribute filter that must be met for this achievement to be completed.
8
8
  # Only present if the achievement has an event filter configured.
9
- class AchievementWithStatsResponseEventAttribute
9
+ class AchievementResponseEventAttribute
10
10
  # @return [String] The key of the event attribute.
11
11
  attr_reader :key
12
12
  # @return [String] The value of the event attribute.
@@ -22,7 +22,7 @@ module TrophyApiClient
22
22
  # @param key [String] The key of the event attribute.
23
23
  # @param value [String] The value of the event attribute.
24
24
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
25
- # @return [TrophyApiClient::AchievementWithStatsResponseEventAttribute]
25
+ # @return [TrophyApiClient::AchievementResponseEventAttribute]
26
26
  def initialize(key:, value:, additional_properties: nil)
27
27
  @key = key
28
28
  @value = value
@@ -30,11 +30,10 @@ module TrophyApiClient
30
30
  @_field_set = { "key": key, "value": value }
31
31
  end
32
32
 
33
- # Deserialize a JSON object to an instance of
34
- # AchievementWithStatsResponseEventAttribute
33
+ # Deserialize a JSON object to an instance of AchievementResponseEventAttribute
35
34
  #
36
35
  # @param json_object [String]
37
- # @return [TrophyApiClient::AchievementWithStatsResponseEventAttribute]
36
+ # @return [TrophyApiClient::AchievementResponseEventAttribute]
38
37
  def self.from_json(json_object:)
39
38
  struct = JSON.parse(json_object, object_class: OpenStruct)
40
39
  parsed_json = JSON.parse(json_object)
@@ -47,8 +46,7 @@ module TrophyApiClient
47
46
  )
48
47
  end
49
48
 
50
- # Serialize an instance of AchievementWithStatsResponseEventAttribute to a JSON
51
- # object
49
+ # Serialize an instance of AchievementResponseEventAttribute to a JSON object
52
50
  #
53
51
  # @return [String]
54
52
  def to_json(*_args)
@@ -4,7 +4,7 @@ require "ostruct"
4
4
  require "json"
5
5
 
6
6
  module TrophyApiClient
7
- class AchievementWithStatsResponseUserAttributesItem
7
+ class AchievementResponseUserAttributesItem
8
8
  # @return [String] The key of the user attribute.
9
9
  attr_reader :key
10
10
  # @return [String] The value of the user attribute.
@@ -20,7 +20,7 @@ module TrophyApiClient
20
20
  # @param key [String] The key of the user attribute.
21
21
  # @param value [String] The value of the user attribute.
22
22
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
23
- # @return [TrophyApiClient::AchievementWithStatsResponseUserAttributesItem]
23
+ # @return [TrophyApiClient::AchievementResponseUserAttributesItem]
24
24
  def initialize(key:, value:, additional_properties: nil)
25
25
  @key = key
26
26
  @value = value
@@ -29,10 +29,10 @@ module TrophyApiClient
29
29
  end
30
30
 
31
31
  # Deserialize a JSON object to an instance of
32
- # AchievementWithStatsResponseUserAttributesItem
32
+ # AchievementResponseUserAttributesItem
33
33
  #
34
34
  # @param json_object [String]
35
- # @return [TrophyApiClient::AchievementWithStatsResponseUserAttributesItem]
35
+ # @return [TrophyApiClient::AchievementResponseUserAttributesItem]
36
36
  def self.from_json(json_object:)
37
37
  struct = JSON.parse(json_object, object_class: OpenStruct)
38
38
  parsed_json = JSON.parse(json_object)
@@ -45,8 +45,7 @@ module TrophyApiClient
45
45
  )
46
46
  end
47
47
 
48
- # Serialize an instance of AchievementWithStatsResponseUserAttributesItem to a
49
- # JSON object
48
+ # Serialize an instance of AchievementResponseUserAttributesItem to a JSON object
50
49
  #
51
50
  # @return [String]
52
51
  def to_json(*_args)
@@ -1,8 +1,8 @@
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"
5
3
  require_relative "achievement_response_trigger"
4
+ require_relative "achievement_response_user_attributes_item"
5
+ require_relative "achievement_response_event_attribute"
6
6
  require "ostruct"
7
7
  require "json"
8
8
 
@@ -12,12 +12,6 @@ module TrophyApiClient
12
12
  attr_reader :completions
13
13
  # @return [Float] The percentage of all users who have completed this achievement.
14
14
  attr_reader :rarity
15
- # @return [Array<TrophyApiClient::AchievementWithStatsResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
16
- # Only present if the achievement has user attribute filters configured.
17
- attr_reader :user_attributes
18
- # @return [TrophyApiClient::AchievementWithStatsResponseEventAttribute] Event attribute filter that must be met for this achievement to be completed.
19
- # Only present if the achievement has an event filter configured.
20
- attr_reader :event_attribute
21
15
  # @return [String] The unique ID of the achievement.
22
16
  attr_reader :id
23
17
  # @return [String] The name of this achievement.
@@ -43,6 +37,12 @@ module TrophyApiClient
43
37
  # @return [String] The name of the metric associated with this achievement (only applicable if
44
38
  # trigger = 'metric')
45
39
  attr_reader :metric_name
40
+ # @return [Array<TrophyApiClient::AchievementResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
41
+ # Only present if the achievement has user attribute filters configured.
42
+ attr_reader :user_attributes
43
+ # @return [TrophyApiClient::AchievementResponseEventAttribute] Event attribute filter that must be met for this achievement to be completed.
44
+ # Only present if the achievement has an event filter configured.
45
+ attr_reader :event_attribute
46
46
  # @return [OpenStruct] Additional properties unmapped to the current class definition
47
47
  attr_reader :additional_properties
48
48
  # @return [Object]
@@ -53,10 +53,6 @@ module TrophyApiClient
53
53
 
54
54
  # @param completions [Integer] The number of users who have completed this achievement.
55
55
  # @param rarity [Float] The percentage of all users who have completed this achievement.
56
- # @param user_attributes [Array<TrophyApiClient::AchievementWithStatsResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
57
- # Only present if the achievement has user attribute filters configured.
58
- # @param event_attribute [TrophyApiClient::AchievementWithStatsResponseEventAttribute] Event attribute filter that must be met for this achievement to be completed.
59
- # Only present if the achievement has an event filter configured.
60
56
  # @param id [String] The unique ID of the achievement.
61
57
  # @param name [String] The name of this achievement.
62
58
  # @param trigger [TrophyApiClient::AchievementResponseTrigger] The trigger of the achievement.
@@ -72,30 +68,32 @@ module TrophyApiClient
72
68
  # trigger = 'metric')
73
69
  # @param metric_name [String] The name of the metric associated with this achievement (only applicable if
74
70
  # trigger = 'metric')
71
+ # @param user_attributes [Array<TrophyApiClient::AchievementResponseUserAttributesItem>] User attribute filters that must be met for this achievement to be completed.
72
+ # Only present if the achievement has user attribute filters configured.
73
+ # @param event_attribute [TrophyApiClient::AchievementResponseEventAttribute] Event attribute filter that must be met for this achievement to be completed.
74
+ # Only present if the achievement has an event filter configured.
75
75
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
76
76
  # @return [TrophyApiClient::AchievementWithStatsResponse]
77
- def initialize(completions:, rarity:, id:, name:, trigger:, key:, user_attributes: OMIT, event_attribute: OMIT,
78
- description: OMIT, badge_url: OMIT, streak_length: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, additional_properties: nil)
77
+ def initialize(completions:, rarity:, id:, name:, trigger:, description: OMIT, badge_url: OMIT, key: OMIT,
78
+ streak_length: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, user_attributes: OMIT, event_attribute: OMIT, additional_properties: nil)
79
79
  @completions = completions
80
80
  @rarity = rarity
81
- @user_attributes = user_attributes if user_attributes != OMIT
82
- @event_attribute = event_attribute if event_attribute != OMIT
83
81
  @id = id
84
82
  @name = name
85
83
  @trigger = trigger
86
84
  @description = description if description != OMIT
87
85
  @badge_url = badge_url if badge_url != OMIT
88
- @key = key
86
+ @key = key if key != OMIT
89
87
  @streak_length = streak_length if streak_length != OMIT
90
88
  @metric_id = metric_id if metric_id != OMIT
91
89
  @metric_value = metric_value if metric_value != OMIT
92
90
  @metric_name = metric_name if metric_name != OMIT
91
+ @user_attributes = user_attributes if user_attributes != OMIT
92
+ @event_attribute = event_attribute if event_attribute != OMIT
93
93
  @additional_properties = additional_properties
94
94
  @_field_set = {
95
95
  "completions": completions,
96
96
  "rarity": rarity,
97
- "userAttributes": user_attributes,
98
- "eventAttribute": event_attribute,
99
97
  "id": id,
100
98
  "name": name,
101
99
  "trigger": trigger,
@@ -105,7 +103,9 @@ module TrophyApiClient
105
103
  "streakLength": streak_length,
106
104
  "metricId": metric_id,
107
105
  "metricValue": metric_value,
108
- "metricName": metric_name
106
+ "metricName": metric_name,
107
+ "userAttributes": user_attributes,
108
+ "eventAttribute": event_attribute
109
109
  }.reject do |_k, v|
110
110
  v == OMIT
111
111
  end
@@ -120,16 +120,6 @@ module TrophyApiClient
120
120
  parsed_json = JSON.parse(json_object)
121
121
  completions = parsed_json["completions"]
122
122
  rarity = parsed_json["rarity"]
123
- user_attributes = parsed_json["userAttributes"]&.map do |item|
124
- item = item.to_json
125
- TrophyApiClient::AchievementWithStatsResponseUserAttributesItem.from_json(json_object: item)
126
- end
127
- if parsed_json["eventAttribute"].nil?
128
- event_attribute = nil
129
- else
130
- event_attribute = parsed_json["eventAttribute"].to_json
131
- event_attribute = TrophyApiClient::AchievementWithStatsResponseEventAttribute.from_json(json_object: event_attribute)
132
- end
133
123
  id = parsed_json["id"]
134
124
  name = parsed_json["name"]
135
125
  trigger = parsed_json["trigger"]
@@ -140,11 +130,19 @@ module TrophyApiClient
140
130
  metric_id = parsed_json["metricId"]
141
131
  metric_value = parsed_json["metricValue"]
142
132
  metric_name = parsed_json["metricName"]
133
+ user_attributes = parsed_json["userAttributes"]&.map do |item|
134
+ item = item.to_json
135
+ TrophyApiClient::AchievementResponseUserAttributesItem.from_json(json_object: item)
136
+ end
137
+ if parsed_json["eventAttribute"].nil?
138
+ event_attribute = nil
139
+ else
140
+ event_attribute = parsed_json["eventAttribute"].to_json
141
+ event_attribute = TrophyApiClient::AchievementResponseEventAttribute.from_json(json_object: event_attribute)
142
+ end
143
143
  new(
144
144
  completions: completions,
145
145
  rarity: rarity,
146
- user_attributes: user_attributes,
147
- event_attribute: event_attribute,
148
146
  id: id,
149
147
  name: name,
150
148
  trigger: trigger,
@@ -155,6 +153,8 @@ module TrophyApiClient
155
153
  metric_id: metric_id,
156
154
  metric_value: metric_value,
157
155
  metric_name: metric_name,
156
+ user_attributes: user_attributes,
157
+ event_attribute: event_attribute,
158
158
  additional_properties: struct
159
159
  )
160
160
  end
@@ -175,18 +175,18 @@ module TrophyApiClient
175
175
  def self.validate_raw(obj:)
176
176
  obj.completions.is_a?(Integer) != false || raise("Passed value for field obj.completions is not the expected type, validation failed.")
177
177
  obj.rarity.is_a?(Float) != false || raise("Passed value for field obj.rarity is not the expected type, validation failed.")
178
- obj.user_attributes&.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.")
179
- obj.event_attribute.nil? || TrophyApiClient::AchievementWithStatsResponseEventAttribute.validate_raw(obj: obj.event_attribute)
180
178
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
181
179
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
182
180
  obj.trigger.is_a?(TrophyApiClient::AchievementResponseTrigger) != false || raise("Passed value for field obj.trigger is not the expected type, validation failed.")
183
181
  obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
184
182
  obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
185
- obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
183
+ obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
186
184
  obj.streak_length&.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.")
187
185
  obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
188
186
  obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
189
187
  obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
188
+ obj.user_attributes&.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.")
189
+ obj.event_attribute.nil? || TrophyApiClient::AchievementResponseEventAttribute.validate_raw(obj: obj.event_attribute)
190
190
  end
191
191
  end
192
192
  end