Class: TrophyApiClient::PointsTriggerResponse
- Inherits:
-
Object
- Object
- TrophyApiClient::PointsTriggerResponse
- Defined in:
- lib/trophy_api_client/types/points_trigger_response.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#achievement_id ⇒ String
readonly
The unique ID of the achievement associated with this trigger, if the trigger is an achievement.
-
#achievement_name ⇒ String
readonly
The name of the achievement associated with this trigger, if the trigger is an achievement.
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#created ⇒ DateTime
readonly
The date and time the trigger was created, in ISO 8601 format.
-
#id ⇒ String
readonly
The unique ID of the trigger.
-
#metric_id ⇒ String
readonly
The unique ID of the metric associated with this trigger, if the trigger is a metric.
-
#metric_name ⇒ String
readonly
The name of the metric associated with this trigger, if the trigger is a metric.
-
#metric_threshold ⇒ Float
readonly
The amount that a user must increase the metric to earn the points, if the trigger is a metric.
-
#points ⇒ Float
readonly
The points awarded by this trigger.
-
#status ⇒ TrophyApiClient::PointsTriggerResponseStatus
readonly
The status of the trigger.
-
#streak_length_threshold ⇒ Float
readonly
The number of consecutive streak periods that a user must complete to earn the points, if the trigger is a streak.
-
#type ⇒ TrophyApiClient::PointsTriggerResponseType
readonly
The type of trigger.
-
#updated ⇒ DateTime
readonly
The date and time the trigger was last updated, in ISO 8601 format.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::PointsTriggerResponse
Deserialize a JSON object to an instance of PointsTriggerResponse.
-
.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, status: OMIT, achievement_id: OMIT, metric_id: OMIT, metric_threshold: OMIT, streak_length_threshold: OMIT, metric_name: OMIT, achievement_name: OMIT, created: OMIT, updated: OMIT, additional_properties: nil) ⇒ TrophyApiClient::PointsTriggerResponse constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of PointsTriggerResponse to a JSON object.
Constructor Details
#initialize(id: OMIT, type: OMIT, points: OMIT, status: OMIT, achievement_id: OMIT, metric_id: OMIT, metric_threshold: OMIT, streak_length_threshold: OMIT, metric_name: OMIT, achievement_name: OMIT, created: OMIT, updated: OMIT, additional_properties: nil) ⇒ TrophyApiClient::PointsTriggerResponse
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/trophy_api_client/types/points_trigger_response.rb', line 67 def initialize(id: OMIT, type: OMIT, points: OMIT, status: OMIT, achievement_id: OMIT, metric_id: OMIT, metric_threshold: OMIT, streak_length_threshold: OMIT, metric_name: OMIT, achievement_name: OMIT, created: OMIT, updated: OMIT, additional_properties: nil) @id = id if id != OMIT @type = type if type != OMIT @points = points if points != OMIT @status = status if status != OMIT @achievement_id = achievement_id if achievement_id != OMIT @metric_id = metric_id if metric_id != OMIT @metric_threshold = metric_threshold if metric_threshold != OMIT @streak_length_threshold = streak_length_threshold if streak_length_threshold != OMIT @metric_name = metric_name if metric_name != OMIT @achievement_name = achievement_name if achievement_name != OMIT @created = created if created != OMIT @updated = updated if updated != OMIT @additional_properties = additional_properties @_field_set = { "id": id, "type": type, "points": points, "status": status, "achievementId": achievement_id, "metricId": metric_id, "metricThreshold": metric_threshold, "streakLengthThreshold": streak_length_threshold, "metricName": metric_name, "achievementName": achievement_name, "created": created, "updated": updated }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#achievement_id ⇒ String (readonly)
Returns The unique ID of the achievement associated with this trigger, if the trigger is an achievement.
21 22 23 |
# File 'lib/trophy_api_client/types/points_trigger_response.rb', line 21 def achievement_id @achievement_id end |
#achievement_name ⇒ String (readonly)
Returns The name of the achievement associated with this trigger, if the trigger is an achievement.
35 36 37 |
# File 'lib/trophy_api_client/types/points_trigger_response.rb', line 35 def achievement_name @achievement_name end |
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
41 42 43 |
# File 'lib/trophy_api_client/types/points_trigger_response.rb', line 41 def additional_properties @additional_properties end |
#created ⇒ DateTime (readonly)
Returns The date and time the trigger was created, in ISO 8601 format.
37 38 39 |
# File 'lib/trophy_api_client/types/points_trigger_response.rb', line 37 def created @created end |
#id ⇒ String (readonly)
Returns The unique ID of the trigger.
12 13 14 |
# File 'lib/trophy_api_client/types/points_trigger_response.rb', line 12 def id @id end |
#metric_id ⇒ String (readonly)
Returns The unique ID of the metric associated with this trigger, if the trigger is a metric.
24 25 26 |
# File 'lib/trophy_api_client/types/points_trigger_response.rb', line 24 def metric_id @metric_id end |
#metric_name ⇒ String (readonly)
Returns The name of the metric associated with this trigger, if the trigger is a metric.
32 33 34 |
# File 'lib/trophy_api_client/types/points_trigger_response.rb', line 32 def metric_name @metric_name end |
#metric_threshold ⇒ Float (readonly)
Returns The amount that a user must increase the metric to earn the points, if the trigger is a metric.
27 28 29 |
# File 'lib/trophy_api_client/types/points_trigger_response.rb', line 27 def metric_threshold @metric_threshold end |
#points ⇒ Float (readonly)
Returns The points awarded by this trigger.
16 17 18 |
# File 'lib/trophy_api_client/types/points_trigger_response.rb', line 16 def points @points end |
#status ⇒ TrophyApiClient::PointsTriggerResponseStatus (readonly)
Returns The status of the trigger.
18 19 20 |
# File 'lib/trophy_api_client/types/points_trigger_response.rb', line 18 def status @status end |
#streak_length_threshold ⇒ Float (readonly)
Returns The number of consecutive streak periods that a user must complete to earn the points, if the trigger is a streak.
30 31 32 |
# File 'lib/trophy_api_client/types/points_trigger_response.rb', line 30 def streak_length_threshold @streak_length_threshold end |
#type ⇒ TrophyApiClient::PointsTriggerResponseType (readonly)
Returns The type of trigger.
14 15 16 |
# File 'lib/trophy_api_client/types/points_trigger_response.rb', line 14 def type @type end |
#updated ⇒ DateTime (readonly)
Returns The date and time the trigger was last updated, in ISO 8601 format.
39 40 41 |
# File 'lib/trophy_api_client/types/points_trigger_response.rb', line 39 def updated @updated end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::PointsTriggerResponse
Deserialize a JSON object to an instance of PointsTriggerResponse
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/trophy_api_client/types/points_trigger_response.rb', line 104 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"] status = parsed_json["status"] achievement_id = parsed_json["achievementId"] metric_id = parsed_json["metricId"] metric_threshold = parsed_json["metricThreshold"] streak_length_threshold = parsed_json["streakLengthThreshold"] metric_name = parsed_json["metricName"] achievement_name = parsed_json["achievementName"] created = (DateTime.parse(parsed_json["created"]) unless parsed_json["created"].nil?) updated = (DateTime.parse(parsed_json["updated"]) unless parsed_json["updated"].nil?) new( id: id, type: type, points: points, status: status, achievement_id: achievement_id, metric_id: metric_id, metric_threshold: metric_threshold, streak_length_threshold: streak_length_threshold, metric_name: metric_name, achievement_name: achievement_name, created: created, updated: updated, 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.
149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/trophy_api_client/types/points_trigger_response.rb', line 149 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::PointsTriggerResponseType) != 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.status&.is_a?(TrophyApiClient::PointsTriggerResponseStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") obj.achievement_id&.is_a?(String) != false || raise("Passed value for field obj.achievement_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.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.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name 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.created&.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.") obj.updated&.is_a?(DateTime) != false || raise("Passed value for field obj.updated is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of PointsTriggerResponse to a JSON object
139 140 141 |
# File 'lib/trophy_api_client/types/points_trigger_response.rb', line 139 def to_json(*_args) @_field_set&.to_json end |