Class: TrophyApiClient::EventResponse
- Inherits:
-
Object
- Object
- TrophyApiClient::EventResponse
- Defined in:
- lib/trophy_api_client/types/event_response.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#achievements ⇒ Array<TrophyApiClient::EventResponseMetricsItem>
readonly
Changes to achievements as a result of this event.
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#event_id ⇒ String
readonly
The unique ID of the event.
-
#metric_id ⇒ String
readonly
The unique ID of the metric that was updated.
-
#total ⇒ Float
readonly
The user’s new total progress against the metric.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::EventResponse
Deserialize a JSON object to an instance of EventResponse.
-
.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(event_id:, metric_id:, total:, achievements: OMIT, additional_properties: nil) ⇒ TrophyApiClient::EventResponse constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of EventResponse to a JSON object.
Constructor Details
#initialize(event_id:, metric_id:, total:, achievements: OMIT, additional_properties: nil) ⇒ TrophyApiClient::EventResponse
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/trophy_api_client/types/event_response.rb', line 31 def initialize(event_id:, metric_id:, total:, achievements: OMIT, additional_properties: nil) @event_id = event_id @metric_id = metric_id @total = total @achievements = achievements if achievements != OMIT @additional_properties = additional_properties @_field_set = { "eventId": event_id, "metricId": metric_id, "total": total, "achievements": achievements }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#achievements ⇒ Array<TrophyApiClient::EventResponseMetricsItem> (readonly)
Returns Changes to achievements as a result of this event.
16 17 18 |
# File 'lib/trophy_api_client/types/event_response.rb', line 16 def achievements @achievements end |
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
18 19 20 |
# File 'lib/trophy_api_client/types/event_response.rb', line 18 def additional_properties @additional_properties end |
#event_id ⇒ String (readonly)
Returns The unique ID of the event.
10 11 12 |
# File 'lib/trophy_api_client/types/event_response.rb', line 10 def event_id @event_id end |
#metric_id ⇒ String (readonly)
Returns The unique ID of the metric that was updated.
12 13 14 |
# File 'lib/trophy_api_client/types/event_response.rb', line 12 def metric_id @metric_id end |
#total ⇒ Float (readonly)
Returns The user’s new total progress against the metric.
14 15 16 |
# File 'lib/trophy_api_client/types/event_response.rb', line 14 def total @total end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::EventResponse
Deserialize a JSON object to an instance of EventResponse
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/trophy_api_client/types/event_response.rb', line 51 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) event_id = parsed_json["eventId"] metric_id = parsed_json["metricId"] total = parsed_json["total"] achievements = parsed_json["achievements"]&.map do |item| item = item.to_json TrophyApiClient::EventResponseMetricsItem.from_json(json_object: item) end new( event_id: event_id, metric_id: metric_id, total: total, 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.
83 84 85 86 87 88 |
# File 'lib/trophy_api_client/types/event_response.rb', line 83 def self.validate_raw(obj:) obj.event_id.is_a?(String) != false || raise("Passed value for field obj.event_id 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.total.is_a?(Float) != false || raise("Passed value for field obj.total 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 EventResponse to a JSON object
73 74 75 |
# File 'lib/trophy_api_client/types/event_response.rb', line 73 def to_json(*_args) @_field_set&.to_json end |