Class: TrophyApiClient::CreatePointsTriggerRequestItem
- Inherits:
-
Object
- Object
- TrophyApiClient::CreatePointsTriggerRequestItem
- Defined in:
- lib/trophy_api_client/types/create_points_trigger_request_item.rb
Overview
A points trigger to create.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#achievement_id ⇒ String
readonly
Required if type is ‘achievement`.
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#block_if_out_of_points ⇒ Boolean
readonly
Whether to block metric events that would reduce the user’s points below zero.
-
#event_attributes ⇒ Array<TrophyApiClient::CreatePointsTriggerRequestItemEventAttributesItem>
readonly
Optional event attribute filters.
-
#metric_id ⇒ String
readonly
Required if type is ‘metric`.
-
#metric_threshold ⇒ Integer
readonly
Required if type is ‘metric`.
-
#points ⇒ Integer
readonly
The number of points to award or deduct when the trigger fires.
-
#status ⇒ TrophyApiClient::CreatePointsTriggerRequestItemStatus
readonly
The status of the trigger.
-
#streak_length ⇒ Integer
readonly
Required if type is ‘streak`.
-
#time_interval ⇒ Integer
readonly
Required if type is ‘time`.
-
#time_unit ⇒ TrophyApiClient::CreatePointsTriggerRequestItemTimeUnit
readonly
Required if type is ‘time`.
-
#type ⇒ TrophyApiClient::CreatePointsTriggerRequestItemType
readonly
The type of trigger.
-
#user_attributes ⇒ Array<TrophyApiClient::CreatePointsTriggerRequestItemUserAttributesItem>
readonly
Optional user attribute filters for the trigger.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::CreatePointsTriggerRequestItem
Deserialize a JSON object to an instance of CreatePointsTriggerRequestItem.
-
.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(type:, points:, status: OMIT, user_attributes: OMIT, metric_id: OMIT, metric_threshold: OMIT, event_attributes: OMIT, achievement_id: OMIT, streak_length: OMIT, time_unit: OMIT, time_interval: OMIT, block_if_out_of_points: OMIT, additional_properties: nil) ⇒ TrophyApiClient::CreatePointsTriggerRequestItem constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of CreatePointsTriggerRequestItem to a JSON object.
Constructor Details
#initialize(type:, points:, status: OMIT, user_attributes: OMIT, metric_id: OMIT, metric_threshold: OMIT, event_attributes: OMIT, achievement_id: OMIT, streak_length: OMIT, time_unit: OMIT, time_interval: OMIT, block_if_out_of_points: OMIT, additional_properties: nil) ⇒ TrophyApiClient::CreatePointsTriggerRequestItem
64 65 66 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 |
# File 'lib/trophy_api_client/types/create_points_trigger_request_item.rb', line 64 def initialize(type:, points:, status: OMIT, user_attributes: OMIT, metric_id: OMIT, metric_threshold: OMIT, event_attributes: OMIT, achievement_id: OMIT, streak_length: OMIT, time_unit: OMIT, time_interval: OMIT, block_if_out_of_points: OMIT, additional_properties: nil) @type = type @points = points @status = status if status != OMIT @user_attributes = user_attributes if user_attributes != OMIT @metric_id = metric_id if metric_id != OMIT @metric_threshold = metric_threshold if metric_threshold != OMIT @event_attributes = event_attributes if event_attributes != OMIT @achievement_id = achievement_id if achievement_id != OMIT @streak_length = streak_length if streak_length != OMIT @time_unit = time_unit if time_unit != OMIT @time_interval = time_interval if time_interval != OMIT @block_if_out_of_points = block_if_out_of_points if block_if_out_of_points != OMIT @additional_properties = additional_properties @_field_set = { "type": type, "points": points, "status": status, "userAttributes": user_attributes, "metricId": metric_id, "metricThreshold": metric_threshold, "eventAttributes": event_attributes, "achievementId": achievement_id, "streakLength": streak_length, "timeUnit": time_unit, "timeInterval": time_interval, "blockIfOutOfPoints": block_if_out_of_points }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#achievement_id ⇒ String (readonly)
Returns Required if type is ‘achievement`. The UUID of the achievement.
29 30 31 |
# File 'lib/trophy_api_client/types/create_points_trigger_request_item.rb', line 29 def achievement_id @achievement_id end |
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
41 42 43 |
# File 'lib/trophy_api_client/types/create_points_trigger_request_item.rb', line 41 def additional_properties @additional_properties end |
#block_if_out_of_points ⇒ Boolean (readonly)
Returns Whether to block metric events that would reduce the user’s points below zero. Defaults to false.
39 40 41 |
# File 'lib/trophy_api_client/types/create_points_trigger_request_item.rb', line 39 def block_if_out_of_points @block_if_out_of_points end |
#event_attributes ⇒ Array<TrophyApiClient::CreatePointsTriggerRequestItemEventAttributesItem> (readonly)
Returns Optional event attribute filters. Only permitted if type is ‘metric`.
27 28 29 |
# File 'lib/trophy_api_client/types/create_points_trigger_request_item.rb', line 27 def event_attributes @event_attributes end |
#metric_id ⇒ String (readonly)
Returns Required if type is ‘metric`. The UUID of the metric.
23 24 25 |
# File 'lib/trophy_api_client/types/create_points_trigger_request_item.rb', line 23 def metric_id @metric_id end |
#metric_threshold ⇒ Integer (readonly)
Returns Required if type is ‘metric`. The metric increment that triggers the points.
25 26 27 |
# File 'lib/trophy_api_client/types/create_points_trigger_request_item.rb', line 25 def metric_threshold @metric_threshold end |
#points ⇒ Integer (readonly)
Returns The number of points to award or deduct when the trigger fires. Cannot be zero.
17 18 19 |
# File 'lib/trophy_api_client/types/create_points_trigger_request_item.rb', line 17 def points @points end |
#status ⇒ TrophyApiClient::CreatePointsTriggerRequestItemStatus (readonly)
Returns The status of the trigger. Defaults to ‘inactive’.
19 20 21 |
# File 'lib/trophy_api_client/types/create_points_trigger_request_item.rb', line 19 def status @status end |
#streak_length ⇒ Integer (readonly)
Returns Required if type is ‘streak`. The number of streak periods that triggers the points.
32 33 34 |
# File 'lib/trophy_api_client/types/create_points_trigger_request_item.rb', line 32 def streak_length @streak_length end |
#time_interval ⇒ Integer (readonly)
Returns Required if type is ‘time`. The number of time units between recurring awards.
36 37 38 |
# File 'lib/trophy_api_client/types/create_points_trigger_request_item.rb', line 36 def time_interval @time_interval end |
#time_unit ⇒ TrophyApiClient::CreatePointsTriggerRequestItemTimeUnit (readonly)
Returns Required if type is ‘time`. The unit for the time interval.
34 35 36 |
# File 'lib/trophy_api_client/types/create_points_trigger_request_item.rb', line 34 def time_unit @time_unit end |
#type ⇒ TrophyApiClient::CreatePointsTriggerRequestItemType (readonly)
Returns The type of trigger.
15 16 17 |
# File 'lib/trophy_api_client/types/create_points_trigger_request_item.rb', line 15 def type @type end |
#user_attributes ⇒ Array<TrophyApiClient::CreatePointsTriggerRequestItemUserAttributesItem> (readonly)
Returns Optional user attribute filters for the trigger.
21 22 23 |
# File 'lib/trophy_api_client/types/create_points_trigger_request_item.rb', line 21 def user_attributes @user_attributes end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::CreatePointsTriggerRequestItem
Deserialize a JSON object to an instance of CreatePointsTriggerRequestItem
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 136 137 |
# File 'lib/trophy_api_client/types/create_points_trigger_request_item.rb', line 101 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) type = parsed_json["type"] points = parsed_json["points"] status = parsed_json["status"] user_attributes = parsed_json["userAttributes"]&.map do |item| item = item.to_json TrophyApiClient::CreatePointsTriggerRequestItemUserAttributesItem.from_json(json_object: item) end metric_id = parsed_json["metricId"] metric_threshold = parsed_json["metricThreshold"] event_attributes = parsed_json["eventAttributes"]&.map do |item| item = item.to_json TrophyApiClient::CreatePointsTriggerRequestItemEventAttributesItem.from_json(json_object: item) end achievement_id = parsed_json["achievementId"] streak_length = parsed_json["streakLength"] time_unit = parsed_json["timeUnit"] time_interval = parsed_json["timeInterval"] block_if_out_of_points = parsed_json["blockIfOutOfPoints"] new( type: type, points: points, status: status, user_attributes: user_attributes, metric_id: metric_id, metric_threshold: metric_threshold, event_attributes: event_attributes, achievement_id: achievement_id, streak_length: streak_length, time_unit: time_unit, time_interval: time_interval, block_if_out_of_points: block_if_out_of_points, 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.
152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/trophy_api_client/types/create_points_trigger_request_item.rb', line 152 def self.validate_raw(obj:) obj.type.is_a?(TrophyApiClient::CreatePointsTriggerRequestItemType) != 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::CreatePointsTriggerRequestItemStatus) != false || raise("Passed value for field obj.status 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.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?(Integer) != false || raise("Passed value for field obj.metric_threshold is not the expected type, validation failed.") obj.event_attributes&.is_a?(Array) != false || raise("Passed value for field obj.event_attributes 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.streak_length&.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.") obj.time_unit&.is_a?(TrophyApiClient::CreatePointsTriggerRequestItemTimeUnit) != 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.block_if_out_of_points&.is_a?(Boolean) != false || raise("Passed value for field obj.block_if_out_of_points is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of CreatePointsTriggerRequestItem to a JSON object
142 143 144 |
# File 'lib/trophy_api_client/types/create_points_trigger_request_item.rb', line 142 def to_json(*_args) @_field_set&.to_json end |