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::EventResponseMetricsItemCompletedItem>
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 that these achievements are associated with, if any.
-
#trigger ⇒ String
readonly
The trigger of the achievement, in this case either ‘metric’ or ‘streak’.
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(completed:, trigger: OMIT, metric_id: OMIT, additional_properties: nil) ⇒ TrophyApiClient::EventResponseMetricsItem constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of EventResponseMetricsItem to a JSON object.
Constructor Details
#initialize(completed:, trigger: OMIT, metric_id: OMIT, additional_properties: nil) ⇒ TrophyApiClient::EventResponseMetricsItem
30 31 32 33 34 35 36 37 38 |
# File 'lib/trophy_api_client/types/event_response_metrics_item.rb', line 30 def initialize(completed:, trigger: OMIT, metric_id: OMIT, additional_properties: nil) @trigger = trigger if trigger != OMIT @metric_id = metric_id if metric_id != OMIT @completed = completed @additional_properties = additional_properties @_field_set = { "trigger": trigger, "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.
17 18 19 |
# File 'lib/trophy_api_client/types/event_response_metrics_item.rb', line 17 def additional_properties @additional_properties end |
#completed ⇒ Array<TrophyApiClient::EventResponseMetricsItemCompletedItem> (readonly)
Returns A list of any new achievements that the user has now completed as a result of this event being submitted.
15 16 17 |
# File 'lib/trophy_api_client/types/event_response_metrics_item.rb', line 15 def completed @completed end |
#metric_id ⇒ String (readonly)
Returns The ID of the metric that these achievements are associated with, if any.
12 13 14 |
# File 'lib/trophy_api_client/types/event_response_metrics_item.rb', line 12 def metric_id @metric_id end |
#trigger ⇒ String (readonly)
Returns The trigger of the achievement, in this case either ‘metric’ or ‘streak’.
10 11 12 |
# File 'lib/trophy_api_client/types/event_response_metrics_item.rb', line 10 def trigger @trigger end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::EventResponseMetricsItem
Deserialize a JSON object to an instance of EventResponseMetricsItem
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/trophy_api_client/types/event_response_metrics_item.rb', line 44 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) trigger = parsed_json["trigger"] metric_id = parsed_json["metricId"] completed = parsed_json["completed"]&.map do |item| item = item.to_json TrophyApiClient::EventResponseMetricsItemCompletedItem.from_json(json_object: item) end new( trigger: trigger, 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.
74 75 76 77 78 |
# File 'lib/trophy_api_client/types/event_response_metrics_item.rb', line 74 def self.validate_raw(obj:) obj.trigger&.is_a?(String) != false || raise("Passed value for field obj.trigger 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.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
64 65 66 |
# File 'lib/trophy_api_client/types/event_response_metrics_item.rb', line 64 def to_json(*_args) @_field_set&.to_json end |