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.
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:, 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:, additional_properties: nil) ⇒ TrophyApiClient::StreakResponseStreakHistoryItem
28 29 30 31 32 33 34 |
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 28 def initialize(period_start:, period_end:, length:, additional_properties: nil) @period_start = period_start @period_end = period_end @length = length @additional_properties = additional_properties @_field_set = { "periodStart": period_start, "periodEnd": period_end, "length": length } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
16 17 18 |
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 16 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 |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::StreakResponseStreakHistoryItem
Deserialize a JSON object to an instance of StreakResponseStreakHistoryItem
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 40 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"] new( period_start: period_start, period_end: period_end, length: length, 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.
67 68 69 70 71 |
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 67 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.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of StreakResponseStreakHistoryItem to a JSON object
57 58 59 |
# File 'lib/trophy_api_client/types/streak_response_streak_history_item.rb', line 57 def to_json(*_args) @_field_set&.to_json end |