Class: TrophyApiClient::PointsTrigger
- Inherits:
-
Object
- Object
- TrophyApiClient::PointsTrigger
- Defined in:
- lib/trophy_api_client/types/points_trigger.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#achievement_name ⇒ String
readonly
If the trigger has type ‘achievement’, the name of the achievement.
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#id ⇒ String
readonly
The ID of the trigger.
-
#metric_name ⇒ String
readonly
If the trigger has type ‘metric’, the name of the metric.
-
#metric_threshold ⇒ Float
readonly
If the trigger has type ‘metric’, the threshold of the metric that triggers the points.
-
#points ⇒ Float
readonly
The points awarded by this trigger.
-
#streak_length_threshold ⇒ Float
readonly
If the trigger has type ‘streak’, the threshold of the streak that triggers the points.
-
#type ⇒ TrophyApiClient::PointsTriggerType
readonly
The type of trigger.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::PointsTrigger
Deserialize a JSON object to an instance of PointsTrigger.
-
.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: OMIT, type: OMIT, points: OMIT, metric_name: OMIT, metric_threshold: OMIT, streak_length_threshold: OMIT, achievement_name: OMIT, additional_properties: nil) ⇒ TrophyApiClient::PointsTrigger constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of PointsTrigger to a JSON object.
Constructor Details
#initialize(id: OMIT, type: OMIT, points: OMIT, metric_name: OMIT, metric_threshold: OMIT, streak_length_threshold: OMIT, achievement_name: OMIT, additional_properties: nil) ⇒ TrophyApiClient::PointsTrigger
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 44 def initialize(id: OMIT, type: OMIT, points: OMIT, metric_name: OMIT, metric_threshold: OMIT, streak_length_threshold: OMIT, achievement_name: OMIT, additional_properties: nil) @id = id if id != OMIT @type = type if type != OMIT @points = points if points != OMIT @metric_name = metric_name if metric_name != OMIT @metric_threshold = metric_threshold if metric_threshold != OMIT @streak_length_threshold = streak_length_threshold if streak_length_threshold != OMIT @achievement_name = achievement_name if achievement_name != OMIT @additional_properties = additional_properties @_field_set = { "id": id, "type": type, "points": points, "metricName": metric_name, "metricThreshold": metric_threshold, "streakLengthThreshold": streak_length_threshold, "achievementName": achievement_name }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#achievement_name ⇒ String (readonly)
Returns If the trigger has type ‘achievement’, the name of the achievement.
24 25 26 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 24 def achievement_name @achievement_name end |
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
26 27 28 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 26 def additional_properties @additional_properties end |
#id ⇒ String (readonly)
Returns The ID of the trigger.
10 11 12 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 10 def id @id end |
#metric_name ⇒ String (readonly)
Returns If the trigger has type ‘metric’, the name of the metric.
16 17 18 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 16 def metric_name @metric_name end |
#metric_threshold ⇒ Float (readonly)
Returns If the trigger has type ‘metric’, the threshold of the metric that triggers the points.
19 20 21 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 19 def metric_threshold @metric_threshold end |
#points ⇒ Float (readonly)
Returns The points awarded by this trigger.
14 15 16 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 14 def points @points end |
#streak_length_threshold ⇒ Float (readonly)
Returns If the trigger has type ‘streak’, the threshold of the streak that triggers the points.
22 23 24 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 22 def streak_length_threshold @streak_length_threshold end |
#type ⇒ TrophyApiClient::PointsTriggerType (readonly)
Returns The type of trigger.
12 13 14 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 12 def type @type end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::PointsTrigger
Deserialize a JSON object to an instance of PointsTrigger
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 71 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = parsed_json["id"] type = parsed_json["type"] points = parsed_json["points"] metric_name = parsed_json["metricName"] metric_threshold = parsed_json["metricThreshold"] streak_length_threshold = parsed_json["streakLengthThreshold"] achievement_name = parsed_json["achievementName"] new( id: id, type: type, points: points, metric_name: metric_name, metric_threshold: metric_threshold, streak_length_threshold: streak_length_threshold, achievement_name: achievement_name, 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.
106 107 108 109 110 111 112 113 114 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 106 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.type&.is_a?(TrophyApiClient::PointsTriggerType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.points&.is_a?(Float) != false || raise("Passed value for field obj.points is not the expected type, validation failed.") obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.") obj.metric_threshold&.is_a?(Float) != false || raise("Passed value for field obj.metric_threshold is not the expected type, validation failed.") obj.streak_length_threshold&.is_a?(Float) != false || raise("Passed value for field obj.streak_length_threshold is not the expected type, validation failed.") obj.achievement_name&.is_a?(String) != false || raise("Passed value for field obj.achievement_name is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of PointsTrigger to a JSON object
96 97 98 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 96 def to_json(*_args) @_field_set&.to_json end |