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_id ⇒ String
readonly
The unique ID of the achievement associated with this trigger, if the trigger is an achievement.
-
#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.
-
#created ⇒ DateTime
readonly
The date and time the trigger was created, in ISO 8601 format.
-
#event_attribute ⇒ TrophyApiClient::PointsTriggerEventAttribute
readonly
Deprecated.
-
#event_attributes ⇒ Array<TrophyApiClient::PointsTriggerEventAttributesItem>
readonly
If the trigger has type ‘metric’, the event attributes that must match for the trigger to award points.
-
#id ⇒ String
readonly
The 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
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.
-
#status ⇒ TrophyApiClient::PointsTriggerStatus
readonly
The status of the 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.
-
#updated ⇒ DateTime
readonly
The date and time the trigger was last updated, in ISO 8601 format.
-
#user_attributes ⇒ Array<TrophyApiClient::PointsTriggerUserAttributesItem>
readonly
User attribute filters that must be met for this trigger to award points.
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:, type:, points:, status:, user_attributes:, created:, updated:, achievement_id: OMIT, metric_id: OMIT, metric_name: OMIT, metric_threshold: OMIT, streak_length_threshold: OMIT, achievement_name: OMIT, time_unit: OMIT, time_interval: OMIT, event_attribute: OMIT, event_attributes: OMIT, additional_properties: nil) ⇒ TrophyApiClient::PointsTrigger constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of PointsTrigger to a JSON object.
Constructor Details
#initialize(id:, type:, points:, status:, user_attributes:, created:, updated:, achievement_id: OMIT, metric_id: OMIT, metric_name: OMIT, metric_threshold: OMIT, streak_length_threshold: OMIT, achievement_name: OMIT, time_unit: OMIT, time_interval: OMIT, event_attribute: OMIT, event_attributes: OMIT, additional_properties: nil) ⇒ TrophyApiClient::PointsTrigger
94 95 96 97 98 99 100 101 102 103 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 135 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 94 def initialize(id:, type:, points:, status:, user_attributes:, created:, updated:, achievement_id: OMIT, metric_id: OMIT, metric_name: OMIT, metric_threshold: OMIT, streak_length_threshold: OMIT, achievement_name: OMIT, time_unit: OMIT, time_interval: OMIT, event_attribute: OMIT, event_attributes: OMIT, additional_properties: nil) @id = id @type = type @points = points @status = status @achievement_id = achievement_id if achievement_id != OMIT @metric_id = metric_id if metric_id != 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 @user_attributes = user_attributes @event_attribute = event_attribute if event_attribute != OMIT @event_attributes = event_attributes if event_attributes != OMIT @created = created @updated = updated @additional_properties = additional_properties @_field_set = { "id": id, "type": type, "points": points, "status": status, "achievementId": achievement_id, "metricId": metric_id, "metricName": metric_name, "metricThreshold": metric_threshold, "streakLengthThreshold": streak_length_threshold, "achievementName": achievement_name, "timeUnit": time_unit, "timeInterval": time_interval, "userAttributes": user_attributes, "eventAttribute": event_attribute, "eventAttributes": event_attributes, "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.
25 26 27 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 25 def achievement_id @achievement_id end |
#achievement_name ⇒ String (readonly)
Returns If the trigger has type ‘achievement’, the name of the achievement.
38 39 40 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 38 def achievement_name @achievement_name end |
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
59 60 61 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 59 def additional_properties @additional_properties end |
#created ⇒ DateTime (readonly)
Returns The date and time the trigger was created, in ISO 8601 format.
55 56 57 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 55 def created @created end |
#event_attribute ⇒ TrophyApiClient::PointsTriggerEventAttribute (readonly)
Returns Deprecated. Event attribute filter that must be met for this trigger to award points. Only present if the trigger has an event filter configured.
49 50 51 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 49 def event_attribute @event_attribute end |
#event_attributes ⇒ Array<TrophyApiClient::PointsTriggerEventAttributesItem> (readonly)
Returns If the trigger has type ‘metric’, the event attributes that must match for the trigger to award points. Empty when the trigger is metric-based and has no event attribute filters. Omitted for non-metric triggers.
53 54 55 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 53 def event_attributes @event_attributes end |
#id ⇒ String (readonly)
Returns The ID of the trigger.
16 17 18 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 16 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.
28 29 30 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 28 def metric_id @metric_id end |
#metric_name ⇒ String (readonly)
Returns If the trigger has type ‘metric’, the name of the metric.
30 31 32 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 30 def metric_name @metric_name end |
#metric_threshold ⇒ Integer (readonly)
Returns If the trigger has type ‘metric’, the threshold of the metric that triggers the points.
33 34 35 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 33 def metric_threshold @metric_threshold end |
#points ⇒ Integer (readonly)
Returns The points awarded by this trigger.
20 21 22 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 20 def points @points end |
#status ⇒ TrophyApiClient::PointsTriggerStatus (readonly)
Returns The status of the trigger.
22 23 24 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 22 def status @status end |
#streak_length_threshold ⇒ Integer (readonly)
Returns If the trigger has type ‘streak’, the threshold of the streak that triggers the points.
36 37 38 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 36 def streak_length_threshold @streak_length_threshold end |
#time_interval ⇒ Integer (readonly)
Returns If the trigger has type ‘time’, the numer of units of timeUnit after which to award points.
43 44 45 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 43 def time_interval @time_interval end |
#time_unit ⇒ TrophyApiClient::PointsTriggerTimeUnit (readonly)
Returns If the trigger has type ‘time’, the unit of time after which to award points.
40 41 42 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 40 def time_unit @time_unit end |
#type ⇒ TrophyApiClient::PointsTriggerType (readonly)
Returns The type of trigger.
18 19 20 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 18 def type @type end |
#updated ⇒ DateTime (readonly)
Returns The date and time the trigger was last updated, in ISO 8601 format.
57 58 59 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 57 def updated @updated end |
#user_attributes ⇒ Array<TrophyApiClient::PointsTriggerUserAttributesItem> (readonly)
Returns User attribute filters that must be met for this trigger to award points. Empty when the trigger has no user attribute filters configured.
46 47 48 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 46 def user_attributes @user_attributes end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::PointsTrigger
Deserialize a JSON object to an instance of PointsTrigger
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 141 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_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"] user_attributes = parsed_json["userAttributes"]&.map do |item| item = item.to_json TrophyApiClient::PointsTriggerUserAttributesItem.from_json(json_object: item) end if parsed_json["eventAttribute"].nil? event_attribute = nil else event_attribute = parsed_json["eventAttribute"].to_json event_attribute = TrophyApiClient::PointsTriggerEventAttribute.from_json(json_object: event_attribute) end event_attributes = parsed_json["eventAttributes"]&.map do |item| item = item.to_json TrophyApiClient::PointsTriggerEventAttributesItem.from_json(json_object: item) end 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_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, user_attributes: user_attributes, event_attribute: event_attribute, event_attributes: event_attributes, 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.
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 207 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.status.is_a?(TrophyApiClient::PointsTriggerStatus) != 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_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.") obj.user_attributes.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.") obj.event_attribute.nil? || TrophyApiClient::PointsTriggerEventAttribute.validate_raw(obj: obj.event_attribute) obj.event_attributes&.is_a?(Array) != false || raise("Passed value for field obj.event_attributes 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 PointsTrigger to a JSON object
197 198 199 |
# File 'lib/trophy_api_client/types/points_trigger.rb', line 197 def to_json(*_args) @_field_set&.to_json end |