Class: TrophyApiClient::StreakResponseStreakHistoryItem
- Inherits:
-
Object
- Object
- TrophyApiClient::StreakResponseStreakHistoryItem
- Defined in:
- lib/trophy_api_client/types/streak_response_streak_history_item.rb
Overview
An object representing a past streak period.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#length ⇒ Integer
readonly
The length of the user’s streak during this period.
-
#period_end ⇒ String
readonly
The date this streak period ended.
-
#period_start ⇒ String
readonly
The date this streak period started.
-
#used_freeze ⇒ Boolean
readonly
Whether the user used a streak freeze during this period.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::StreakResponseStreakHistoryItem
Deserialize a JSON object to an instance of StreakResponseStreakHistoryItem.
-
.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(period_start:, period_end:, length:, used_freeze: OMIT, additional_properties: nil) ⇒ TrophyApiClient::StreakResponseStreakHistoryItem constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of StreakResponseStreakHistoryItem to a JSON object.
Constructor Details
#initialize(period_start:, period_end:, length:, used_freeze: OMIT, additional_properties: nil) ⇒ TrophyApiClient::StreakResponseStreakHistoryItem
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 33 def initialize(period_start:, period_end:, length:, used_freeze: OMIT, additional_properties: nil) @period_start = period_start @period_end = period_end @length = length @used_freeze = used_freeze if used_freeze != OMIT @additional_properties = additional_properties @_field_set = { "periodStart": period_start, "periodEnd": period_end, "length": length, "usedFreeze": used_freeze }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
19 20 21 |
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 19 def additional_properties @additional_properties end |
#length ⇒ Integer (readonly)
Returns The length of the user’s streak during this period.
14 15 16 |
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 14 def length @length end |
#period_end ⇒ String (readonly)
Returns The date this streak period ended.
12 13 14 |
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 12 def period_end @period_end end |
#period_start ⇒ String (readonly)
Returns The date this streak period started.
10 11 12 |
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 10 def period_start @period_start end |
#used_freeze ⇒ Boolean (readonly)
Returns Whether the user used a streak freeze during this period. Only present if the organization has enabled streak freezes.
17 18 19 |
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 17 def used_freeze @used_freeze end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::StreakResponseStreakHistoryItem
Deserialize a JSON object to an instance of StreakResponseStreakHistoryItem
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 53 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) period_start = parsed_json["periodStart"] period_end = parsed_json["periodEnd"] length = parsed_json["length"] used_freeze = parsed_json["usedFreeze"] new( period_start: period_start, period_end: period_end, length: length, used_freeze: used_freeze, 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.
82 83 84 85 86 87 |
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 82 def self.validate_raw(obj:) obj.period_start.is_a?(String) != false || raise("Passed value for field obj.period_start is not the expected type, validation failed.") obj.period_end.is_a?(String) != false || raise("Passed value for field obj.period_end is not the expected type, validation failed.") obj.length.is_a?(Integer) != false || raise("Passed value for field obj.length is not the expected type, validation failed.") obj.used_freeze&.is_a?(Boolean) != false || raise("Passed value for field obj.used_freeze is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of StreakResponseStreakHistoryItem to a JSON object
72 73 74 |
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 72 def to_json(*_args) @_field_set&.to_json end |