Class: TrophyApiClient::StreakPreferences
- Inherits:
-
Object
- Object
- TrophyApiClient::StreakPreferences
- Defined in:
- lib/trophy_api_client/types/streak_preferences.rb
Overview
Per-user streak configuration. Requires 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.
- #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(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(evaluation_mode: OMIT, metrics: OMIT, additional_properties: nil) ⇒ TrophyApiClient::StreakPreferences
28 29 30 31 32 33 34 35 |
# File 'lib/trophy_api_client/types/streak_preferences.rb', line 28 def initialize(evaluation_mode: OMIT, metrics: OMIT, additional_properties: nil) @evaluation_mode = evaluation_mode if evaluation_mode != OMIT @metrics = metrics if metrics != OMIT @additional_properties = additional_properties @_field_set = { "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.
17 18 19 |
# File 'lib/trophy_api_client/types/streak_preferences.rb', line 17 def additional_properties @additional_properties end |
#evaluation_mode ⇒ TrophyApiClient::StreakEvaluationModePreference (readonly)
13 14 15 |
# File 'lib/trophy_api_client/types/streak_preferences.rb', line 13 def evaluation_mode @evaluation_mode end |
#metrics ⇒ Array<TrophyApiClient::StreakMetricPreference> (readonly)
Returns Metrics and thresholds that count toward this user’s streak.
15 16 17 |
# File 'lib/trophy_api_client/types/streak_preferences.rb', line 15 def metrics @metrics end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::StreakPreferences
Deserialize a JSON object to an instance of StreakPreferences
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/trophy_api_client/types/streak_preferences.rb', line 41 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) 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( 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.
69 70 71 72 |
# File 'lib/trophy_api_client/types/streak_preferences.rb', line 69 def self.validate_raw(obj:) 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
59 60 61 |
# File 'lib/trophy_api_client/types/streak_preferences.rb', line 59 def to_json(*_args) @_field_set&.to_json end |