Class: TrophyApiClient::AchievementWithStatsResponse
- Inherits:
-
Object
- Object
- TrophyApiClient::AchievementWithStatsResponse
- Defined in:
- lib/trophy_api_client/types/achievement_with_stats_response.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#badge_url ⇒ String
readonly
The URL of the badge image for the achievement, if one has been uploaded.
-
#completions ⇒ Integer
readonly
The number of users who have completed this achievement.
-
#current_streak ⇒ TrophyApiClient::MetricEventStreakResponse
readonly
The user’s current streak for the metric, if the metric has streaks enabled.
-
#description ⇒ String
readonly
The description of this achievement.
-
#event_attribute ⇒ TrophyApiClient::AchievementWithStatsResponseEventAttribute
readonly
Event attribute filter that must be met for this achievement to be completed.
-
#id ⇒ String
readonly
The unique ID of the achievement.
-
#key ⇒ String
readonly
The key used to reference this achievement in the API (only applicable if trigger = ‘api’).
-
#metric_id ⇒ String
readonly
The ID of the metric associated with this achievement (only applicable if trigger = ‘metric’).
-
#metric_name ⇒ String
readonly
The name of the metric associated with this achievement (only applicable if trigger = ‘metric’).
-
#metric_value ⇒ Float
readonly
The value of the metric required to complete the achievement (only applicable if trigger = ‘metric’).
-
#name ⇒ String
readonly
The name of this achievement.
-
#rarity ⇒ Float
readonly
The percentage of all users who have completed this achievement.
-
#streak_length ⇒ Integer
readonly
The length of the streak required to complete the achievement (only applicable if trigger = ‘streak’).
-
#trigger ⇒ TrophyApiClient::AchievementResponseTrigger
readonly
The trigger of the achievement.
-
#user_attributes ⇒ Array<TrophyApiClient::AchievementWithStatsResponseUserAttributesItem>
readonly
User attribute filters that must be met for this achievement to be completed.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::AchievementWithStatsResponse
Deserialize a JSON object to an instance of AchievementWithStatsResponse.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(id:, name:, trigger:, completions: OMIT, rarity: OMIT, user_attributes: OMIT, event_attribute: OMIT, 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) ⇒ TrophyApiClient::AchievementWithStatsResponse constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of AchievementWithStatsResponse to a JSON object.
Constructor Details
#initialize(id:, name:, trigger:, completions: OMIT, rarity: OMIT, user_attributes: OMIT, event_attribute: OMIT, 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) ⇒ TrophyApiClient::AchievementWithStatsResponse
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/trophy_api_client/types/achievement_with_stats_response.rb', line 81 def initialize(id:, name:, trigger:, completions: OMIT, rarity: OMIT, user_attributes: OMIT, event_attribute: OMIT, 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) @completions = completions if completions != OMIT @rarity = rarity if rarity != OMIT @user_attributes = user_attributes if user_attributes != OMIT @event_attribute = event_attribute if event_attribute != OMIT @id = id @name = name @trigger = trigger @description = description if description != OMIT @badge_url = badge_url if badge_url != OMIT @key = key if key != OMIT @streak_length = streak_length if streak_length != OMIT @metric_id = metric_id if metric_id != OMIT @metric_value = metric_value if metric_value != OMIT @metric_name = metric_name if metric_name != OMIT @current_streak = current_streak if current_streak != OMIT @additional_properties = additional_properties @_field_set = { "completions": completions, "rarity": rarity, "userAttributes": user_attributes, "eventAttribute": event_attribute, "id": id, "name": name, "trigger": trigger, "description": description, "badgeUrl": badge_url, "key": key, "streakLength": streak_length, "metricId": metric_id, "metricValue": metric_value, "metricName": metric_name, "currentStreak": current_streak }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
50 51 52 |
# File 'lib/trophy_api_client/types/achievement_with_stats_response.rb', line 50 def additional_properties @additional_properties end |
#badge_url ⇒ String (readonly)
Returns The URL of the badge image for the achievement, if one has been uploaded.
31 32 33 |
# File 'lib/trophy_api_client/types/achievement_with_stats_response.rb', line 31 def badge_url @badge_url end |
#completions ⇒ Integer (readonly)
Returns The number of users who have completed this achievement.
13 14 15 |
# File 'lib/trophy_api_client/types/achievement_with_stats_response.rb', line 13 def completions @completions end |
#current_streak ⇒ TrophyApiClient::MetricEventStreakResponse (readonly)
Returns The user’s current streak for the metric, if the metric has streaks enabled.
48 49 50 |
# File 'lib/trophy_api_client/types/achievement_with_stats_response.rb', line 48 def current_streak @current_streak end |
#description ⇒ String (readonly)
Returns The description of this achievement.
29 30 31 |
# File 'lib/trophy_api_client/types/achievement_with_stats_response.rb', line 29 def description @description end |
#event_attribute ⇒ TrophyApiClient::AchievementWithStatsResponseEventAttribute (readonly)
Returns Event attribute filter that must be met for this achievement to be completed. Only present if the achievement has an event filter configured.
21 22 23 |
# File 'lib/trophy_api_client/types/achievement_with_stats_response.rb', line 21 def event_attribute @event_attribute end |
#id ⇒ String (readonly)
Returns The unique ID of the achievement.
23 24 25 |
# File 'lib/trophy_api_client/types/achievement_with_stats_response.rb', line 23 def id @id end |
#key ⇒ String (readonly)
Returns The key used to reference this achievement in the API (only applicable if trigger = ‘api’).
34 35 36 |
# File 'lib/trophy_api_client/types/achievement_with_stats_response.rb', line 34 def key @key end |
#metric_id ⇒ String (readonly)
Returns The ID of the metric associated with this achievement (only applicable if trigger = ‘metric’).
40 41 42 |
# File 'lib/trophy_api_client/types/achievement_with_stats_response.rb', line 40 def metric_id @metric_id end |
#metric_name ⇒ String (readonly)
Returns The name of the metric associated with this achievement (only applicable if trigger = ‘metric’).
46 47 48 |
# File 'lib/trophy_api_client/types/achievement_with_stats_response.rb', line 46 def metric_name @metric_name end |
#metric_value ⇒ Float (readonly)
Returns The value of the metric required to complete the achievement (only applicable if trigger = ‘metric’).
43 44 45 |
# File 'lib/trophy_api_client/types/achievement_with_stats_response.rb', line 43 def metric_value @metric_value end |
#name ⇒ String (readonly)
Returns The name of this achievement.
25 26 27 |
# File 'lib/trophy_api_client/types/achievement_with_stats_response.rb', line 25 def name @name end |
#rarity ⇒ Float (readonly)
Returns The percentage of all users who have completed this achievement.
15 16 17 |
# File 'lib/trophy_api_client/types/achievement_with_stats_response.rb', line 15 def rarity @rarity end |
#streak_length ⇒ Integer (readonly)
Returns The length of the streak required to complete the achievement (only applicable if trigger = ‘streak’).
37 38 39 |
# File 'lib/trophy_api_client/types/achievement_with_stats_response.rb', line 37 def streak_length @streak_length end |
#trigger ⇒ TrophyApiClient::AchievementResponseTrigger (readonly)
Returns The trigger of the achievement.
27 28 29 |
# File 'lib/trophy_api_client/types/achievement_with_stats_response.rb', line 27 def trigger @trigger end |
#user_attributes ⇒ Array<TrophyApiClient::AchievementWithStatsResponseUserAttributesItem> (readonly)
Returns User attribute filters that must be met for this achievement to be completed. Only present if the achievement has user attribute filters configured.
18 19 20 |
# File 'lib/trophy_api_client/types/achievement_with_stats_response.rb', line 18 def user_attributes @user_attributes end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::AchievementWithStatsResponse
Deserialize a JSON object to an instance of AchievementWithStatsResponse
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/trophy_api_client/types/achievement_with_stats_response.rb', line 124 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) completions = parsed_json["completions"] rarity = parsed_json["rarity"] user_attributes = parsed_json["userAttributes"]&.map do |item| item = item.to_json TrophyApiClient::AchievementWithStatsResponseUserAttributesItem.from_json(json_object: item) end if parsed_json["eventAttribute"].nil? event_attribute = nil else event_attribute = parsed_json["eventAttribute"].to_json event_attribute = TrophyApiClient::AchievementWithStatsResponseEventAttribute.from_json(json_object: event_attribute) end id = parsed_json["id"] name = parsed_json["name"] trigger = parsed_json["trigger"] description = parsed_json["description"] badge_url = parsed_json["badgeUrl"] key = parsed_json["key"] streak_length = parsed_json["streakLength"] metric_id = parsed_json["metricId"] metric_value = parsed_json["metricValue"] metric_name = parsed_json["metricName"] if parsed_json["currentStreak"].nil? current_streak = nil else current_streak = parsed_json["currentStreak"].to_json current_streak = TrophyApiClient::MetricEventStreakResponse.from_json(json_object: current_streak) end new( completions: completions, rarity: rarity, user_attributes: user_attributes, event_attribute: event_attribute, id: id, name: name, trigger: trigger, description: description, badge_url: badge_url, key: key, streak_length: streak_length, metric_id: metric_id, metric_value: metric_value, metric_name: metric_name, current_streak: current_streak, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given
hash and check each fields type against the current object's property
definitions.
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/trophy_api_client/types/achievement_with_stats_response.rb', line 188 def self.validate_raw(obj:) obj.completions&.is_a?(Integer) != false || raise("Passed value for field obj.completions is not the expected type, validation failed.") obj.rarity&.is_a?(Float) != false || raise("Passed value for field obj.rarity is not the expected type, validation failed.") obj.user_attributes&.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.") obj.event_attribute.nil? || TrophyApiClient::AchievementWithStatsResponseEventAttribute.validate_raw(obj: obj.event_attribute) obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") obj.trigger.is_a?(TrophyApiClient::AchievementResponseTrigger) != false || raise("Passed value for field obj.trigger is not the expected type, validation failed.") obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.") obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.") obj.streak_length&.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.") obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.") obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.") obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.") obj.current_streak.nil? || TrophyApiClient::MetricEventStreakResponse.validate_raw(obj: obj.current_streak) end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of AchievementWithStatsResponse to a JSON object
178 179 180 |
# File 'lib/trophy_api_client/types/achievement_with_stats_response.rb', line 178 def to_json(*_args) @_field_set&.to_json end |