Class: TrophyApiClient::EventResponseMetricsItem

Inherits:
Object
  • Object
show all
Defined in:
lib/trophy_api_client/types/event_response_metrics_item.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metric_id: OMIT, completed: OMIT, additional_properties: nil) ⇒ TrophyApiClient::EventResponseMetricsItem

Parameters:

  • metric_id (String) (defaults to: OMIT)

    The ID of the metric.

  • completed (Array<TrophyApiClient::MultiStageAchievementResponse>) (defaults to: OMIT)

    A list of any new achievements that the user has now completed as a result of this event being submitted.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition


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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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

#completedArray<TrophyApiClient::MultiStageAchievementResponse> (readonly)

Returns A list of any new achievements that the user has now completed as a result of this event being submitted.

Returns:


13
14
15
# File 'lib/trophy_api_client/types/event_response_metrics_item.rb', line 13

def completed
  @completed
end

#metric_idString (readonly)

Returns The ID of the metric.

Returns:

  • (String)

    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

Parameters:

  • json_object (String)

Returns:


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.

Parameters:

  • obj (Object)

Returns:

  • (Void)

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

Returns:

  • (String)

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