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 ⇒ Integer
readonly
If the trigger has type ‘metric’, the threshold of the metric that triggers the points.
-
#points ⇒ Integer
readonly
The points awarded by this trigger.
-
#streak_length_threshold ⇒ Integer
readonly
If the trigger has type ‘streak’, the threshold of the streak that triggers the points.
-
#time_interval ⇒ Integer
readonly
If the trigger has type ‘time’, the numer of units of timeUnit after which to award points.
-
#time_unit ⇒ TrophyApiClient::PointsTriggerTimeUnit
readonly
If the trigger has type ‘time’, the unit of time after which to award 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, time_unit: OMIT, time_interval: 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, time_unit: OMIT, time_interval: OMIT, additional_properties: nil) ⇒ TrophyApiClient::PointsTrigger
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 53 def initialize(id: OMIT, type: OMIT, points: OMIT, metric_name: OMIT, metric_threshold: OMIT, streak_length_threshold: OMIT, achievement_name: OMIT, time_unit: OMIT, time_interval: 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 @time_unit = time_unit if time_unit != OMIT @time_interval = time_interval if time_interval != 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, "timeUnit": time_unit, "timeInterval": time_interval }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#achievement_name ⇒ String (readonly)
25 26 27 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 25 def achievement_name @achievement_name end |
#additional_properties ⇒ OpenStruct (readonly)
32 33 34 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 32 def additional_properties @additional_properties end |
#id ⇒ String (readonly)
11 12 13 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 11 def id @id end |
#metric_name ⇒ String (readonly)
17 18 19 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 17 def metric_name @metric_name end |
#metric_threshold ⇒ Integer (readonly)
20 21 22 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 20 def metric_threshold @metric_threshold end |
#points ⇒ Integer (readonly)
15 16 17 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 15 def points @points end |
#streak_length_threshold ⇒ Integer (readonly)
23 24 25 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 23 def streak_length_threshold @streak_length_threshold end |
#time_interval ⇒ Integer (readonly)
30 31 32 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 30 def time_interval @time_interval end |
#time_unit ⇒ TrophyApiClient::PointsTriggerTimeUnit (readonly)
27 28 29 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 27 def time_unit @time_unit end |
#type ⇒ TrophyApiClient::PointsTriggerType (readonly)
13 14 15 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 13 def type @type end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::PointsTrigger
Deserialize a JSON object to an instance of PointsTrigger
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 84 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"] time_unit = parsed_json["timeUnit"] time_interval = parsed_json["timeInterval"] 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, time_unit: time_unit, time_interval: time_interval, 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.
123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 123 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?(Integer) != 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?(Integer) != false || raise("Passed value for field obj.metric_threshold is not the expected type, validation failed.") obj.streak_length_threshold&.is_a?(Integer) != 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.") obj.time_unit&.is_a?(TrophyApiClient::PointsTriggerTimeUnit) != false || raise("Passed value for field obj.time_unit is not the expected type, validation failed.") obj.time_interval&.is_a?(Integer) != false || raise("Passed value for field obj.time_interval is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of PointsTrigger to a JSON object
113 114 115 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 113 def to_json(*_args) @_field_set&.to_json end |