Class: TrophyApiClient::EventResponseMetricsItem
- Inherits:
-
Object
- Object
- TrophyApiClient::EventResponseMetricsItem
- Defined in:
- lib/trophy_api_client/types/event_response_metrics_item.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#completed ⇒ Array<TrophyApiClient::MultiStageAchievementResponse>
readonly
A list of any new achievements that the user has now completed as a result of this event being submitted.
-
#metric_id ⇒ String
readonly
The ID of the metric.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::EventResponseMetricsItem
Deserialize a JSON object to an instance of EventResponseMetricsItem.
-
.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(metric_id: OMIT, completed: OMIT, additional_properties: nil) ⇒ TrophyApiClient::EventResponseMetricsItem constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of EventResponseMetricsItem to a JSON object.
Constructor Details
#initialize(metric_id: OMIT, completed: OMIT, additional_properties: nil) ⇒ TrophyApiClient::EventResponseMetricsItem
27 28 29 30 31 32 33 34 |
# File 'lib/trophy_api_client/types/event_response_metrics_item.rb', line 27 def initialize(metric_id: OMIT, completed: OMIT, additional_properties: nil) @metric_id = metric_id if metric_id != OMIT @completed = completed if completed != OMIT @additional_properties = additional_properties @_field_set = { "metricId": metric_id, "completed": completed }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
15 16 17 |
# File 'lib/trophy_api_client/types/event_response_metrics_item.rb', line 15 def additional_properties @additional_properties end |
#completed ⇒ Array<TrophyApiClient::MultiStageAchievementResponse> (readonly)
Returns A list of any new achievements that the user has now completed as a result of this event being submitted.
13 14 15 |
# File 'lib/trophy_api_client/types/event_response_metrics_item.rb', line 13 def completed @completed end |
#metric_id ⇒ String (readonly)
Returns The ID of the metric.
10 11 12 |
# File 'lib/trophy_api_client/types/event_response_metrics_item.rb', line 10 def metric_id @metric_id end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::EventResponseMetricsItem
Deserialize a JSON object to an instance of EventResponseMetricsItem
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/trophy_api_client/types/event_response_metrics_item.rb', line 40 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) metric_id = parsed_json["metricId"] completed = parsed_json["completed"]&.map do |item| item = item.to_json TrophyApiClient::MultiStageAchievementResponse.from_json(json_object: item) end new( metric_id: metric_id, completed: completed, 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.
68 69 70 71 |
# File 'lib/trophy_api_client/types/event_response_metrics_item.rb', line 68 def self.validate_raw(obj:) obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.") obj.completed&.is_a?(Array) != false || raise("Passed value for field obj.completed is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of EventResponseMetricsItem to a JSON object
58 59 60 |
# File 'lib/trophy_api_client/types/event_response_metrics_item.rb', line 58 def to_json(*_args) @_field_set&.to_json end |