Class: TrophyApiClient::MetricResponse
- Inherits:
-
Object
- Object
- TrophyApiClient::MetricResponse
- Defined in:
- lib/trophy_api_client/types/metric_response.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#achievements ⇒ Array<TrophyApiClient::MultiStageAchievementResponse>
readonly
A list of the metric’s achievements and the user’s progress towards each.
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#current ⇒ Float
readonly
The user’s current total for the metric.
-
#emoji ⇒ String
readonly
The emoji to represent the metric.
-
#id ⇒ String
readonly
The unique ID of the metric.
-
#key ⇒ String
readonly
The unique key of the metric.
-
#name ⇒ String
readonly
The name of the metric.
-
#status ⇒ TrophyApiClient::MetricStatus
readonly
The status of the metric.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::MetricResponse
Deserialize a JSON object to an instance of MetricResponse.
-
.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:, key:, name:, emoji:, status:, current:, achievements:, additional_properties: nil) ⇒ TrophyApiClient::MetricResponse constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of MetricResponse to a JSON object.
Constructor Details
#initialize(id:, key:, name:, emoji:, status:, current:, achievements:, additional_properties: nil) ⇒ TrophyApiClient::MetricResponse
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/trophy_api_client/types/metric_response.rb', line 41 def initialize(id:, key:, name:, emoji:, status:, current:, achievements:, additional_properties: nil) @id = id @key = key @name = name @emoji = emoji @status = status @current = current @achievements = achievements @additional_properties = additional_properties @_field_set = { "id": id, "key": key, "name": name, "emoji": emoji, "status": status, "current": current, "achievements": achievements } end |
Instance Attribute Details
#achievements ⇒ Array<TrophyApiClient::MultiStageAchievementResponse> (readonly)
Returns A list of the metric’s achievements and the user’s progress towards each.
23 24 25 |
# File 'lib/trophy_api_client/types/metric_response.rb', line 23 def achievements @achievements end |
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
25 26 27 |
# File 'lib/trophy_api_client/types/metric_response.rb', line 25 def additional_properties @additional_properties end |
#current ⇒ Float (readonly)
Returns The user’s current total for the metric.
21 22 23 |
# File 'lib/trophy_api_client/types/metric_response.rb', line 21 def current @current end |
#emoji ⇒ String (readonly)
Returns The emoji to represent the metric.
17 18 19 |
# File 'lib/trophy_api_client/types/metric_response.rb', line 17 def emoji @emoji end |
#id ⇒ String (readonly)
Returns The unique ID of the metric.
11 12 13 |
# File 'lib/trophy_api_client/types/metric_response.rb', line 11 def id @id end |
#key ⇒ String (readonly)
Returns The unique key of the metric.
13 14 15 |
# File 'lib/trophy_api_client/types/metric_response.rb', line 13 def key @key end |
#name ⇒ String (readonly)
Returns The name of the metric.
15 16 17 |
# File 'lib/trophy_api_client/types/metric_response.rb', line 15 def name @name end |
#status ⇒ TrophyApiClient::MetricStatus (readonly)
Returns The status of the metric.
19 20 21 |
# File 'lib/trophy_api_client/types/metric_response.rb', line 19 def status @status end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::MetricResponse
Deserialize a JSON object to an instance of MetricResponse
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/trophy_api_client/types/metric_response.rb', line 65 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = parsed_json["id"] key = parsed_json["key"] name = parsed_json["name"] emoji = parsed_json["emoji"] status = parsed_json["status"] current = parsed_json["current"] achievements = parsed_json["achievements"]&.map do |item| item = item.to_json TrophyApiClient::MultiStageAchievementResponse.from_json(json_object: item) end new( id: id, key: key, name: name, emoji: emoji, status: status, current: current, achievements: achievements, 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.
103 104 105 106 107 108 109 110 111 |
# File 'lib/trophy_api_client/types/metric_response.rb', line 103 def self.validate_raw(obj:) obj.id.is_a?(String) != false || raise("Passed value for field obj.id 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.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") obj.emoji.is_a?(String) != false || raise("Passed value for field obj.emoji is not the expected type, validation failed.") obj.status.is_a?(TrophyApiClient::MetricStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") obj.current.is_a?(Float) != false || raise("Passed value for field obj.current is not the expected type, validation failed.") obj.achievements.is_a?(Array) != false || raise("Passed value for field obj.achievements is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of MetricResponse to a JSON object
93 94 95 |
# File 'lib/trophy_api_client/types/metric_response.rb', line 93 def to_json(*_args) @_field_set&.to_json end |