Class: TrophyApiClient::StreakPreferences
- Inherits:
-
Object
- Object
- TrophyApiClient::StreakPreferences
- Defined in:
- lib/trophy_api_client/types/streak_preferences.rb
Overview
Per-user streak configuration. Metric and evaluation mode overrides require
streak customization to be enabled in dashboard settings.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#enabled ⇒ Boolean
readonly
Whether streaks are calculated for this user.
- #evaluation_mode ⇒ TrophyApiClient::StreakEvaluationModePreference readonly
-
#metrics ⇒ Array<TrophyApiClient::StreakMetricPreference>
readonly
Metrics and thresholds that count toward this user’s streak.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::StreakPreferences
Deserialize a JSON object to an instance of StreakPreferences.
-
.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(enabled: OMIT, evaluation_mode: OMIT, metrics: OMIT, additional_properties: nil) ⇒ TrophyApiClient::StreakPreferences constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of StreakPreferences to a JSON object.
Constructor Details
#initialize(enabled: OMIT, evaluation_mode: OMIT, metrics: OMIT, additional_properties: nil) ⇒ TrophyApiClient::StreakPreferences
33 34 35 36 37 38 39 40 41 |
# File 'lib/trophy_api_client/types/streak_preferences.rb', line 33 def initialize(enabled: OMIT, evaluation_mode: OMIT, metrics: OMIT, additional_properties: nil) @enabled = enabled if enabled != OMIT @evaluation_mode = evaluation_mode if evaluation_mode != OMIT @metrics = metrics if metrics != OMIT @additional_properties = additional_properties @_field_set = { "enabled": enabled, "evaluationMode": evaluation_mode, "metrics": metrics }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
20 21 22 |
# File 'lib/trophy_api_client/types/streak_preferences.rb', line 20 def additional_properties @additional_properties end |
#enabled ⇒ Boolean (readonly)
Returns Whether streaks are calculated for this user. When false, the user’s streak is always 0 and streak webhooks and notifications are not sent.
14 15 16 |
# File 'lib/trophy_api_client/types/streak_preferences.rb', line 14 def enabled @enabled end |
#evaluation_mode ⇒ TrophyApiClient::StreakEvaluationModePreference (readonly)
16 17 18 |
# File 'lib/trophy_api_client/types/streak_preferences.rb', line 16 def evaluation_mode @evaluation_mode end |
#metrics ⇒ Array<TrophyApiClient::StreakMetricPreference> (readonly)
Returns Metrics and thresholds that count toward this user’s streak.
18 19 20 |
# File 'lib/trophy_api_client/types/streak_preferences.rb', line 18 def metrics @metrics end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::StreakPreferences
Deserialize a JSON object to an instance of StreakPreferences
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/trophy_api_client/types/streak_preferences.rb', line 47 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) enabled = parsed_json["enabled"] evaluation_mode = parsed_json["evaluationMode"] metrics = parsed_json["metrics"]&.map do |item| item = item.to_json TrophyApiClient::StreakMetricPreference.from_json(json_object: item) end new( enabled: enabled, evaluation_mode: evaluation_mode, metrics: metrics, 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.
77 78 79 80 81 |
# File 'lib/trophy_api_client/types/streak_preferences.rb', line 77 def self.validate_raw(obj:) obj.enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.enabled is not the expected type, validation failed.") obj.evaluation_mode&.is_a?(TrophyApiClient::StreakEvaluationModePreference) != false || raise("Passed value for field obj.evaluation_mode is not the expected type, validation failed.") obj.metrics&.is_a?(Array) != false || raise("Passed value for field obj.metrics is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of StreakPreferences to a JSON object
67 68 69 |
# File 'lib/trophy_api_client/types/streak_preferences.rb', line 67 def to_json(*_args) @_field_set&.to_json end |