Class: TrophyApiClient::WrappedStreak
- Inherits:
-
Object
- Object
- TrophyApiClient::WrappedStreak
- Defined in:
- lib/trophy_api_client/types/wrapped_streak.rb
Overview
The user’s longest streak during the wrapped period.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#frequency ⇒ TrophyApiClient::StreakFrequency
readonly
The frequency of the streak.
-
#length ⇒ Integer
readonly
The length of the streak.
-
#period_end ⇒ String
readonly
The end date of the streak period.
-
#period_start ⇒ String
readonly
The start date of the streak period.
-
#started ⇒ String
readonly
The date the streak started.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::WrappedStreak
Deserialize a JSON object to an instance of WrappedStreak.
-
.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(length:, frequency:, period_start: OMIT, period_end: OMIT, started: OMIT, additional_properties: nil) ⇒ TrophyApiClient::WrappedStreak constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of WrappedStreak to a JSON object.
Constructor Details
#initialize(length:, frequency:, period_start: OMIT, period_end: OMIT, started: OMIT, additional_properties: nil) ⇒ TrophyApiClient::WrappedStreak
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/trophy_api_client/types/wrapped_streak.rb', line 35 def initialize(length:, frequency:, period_start: OMIT, period_end: OMIT, started: OMIT, additional_properties: nil) @length = length @frequency = frequency @period_start = period_start if period_start != OMIT @period_end = period_end if period_end != OMIT @started = started if started != OMIT @additional_properties = additional_properties @_field_set = { "length": length, "frequency": frequency, "periodStart": period_start, "periodEnd": period_end, "started": started }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
21 22 23 |
# File 'lib/trophy_api_client/types/wrapped_streak.rb', line 21 def additional_properties @additional_properties end |
#frequency ⇒ TrophyApiClient::StreakFrequency (readonly)
Returns The frequency of the streak.
13 14 15 |
# File 'lib/trophy_api_client/types/wrapped_streak.rb', line 13 def frequency @frequency end |
#length ⇒ Integer (readonly)
Returns The length of the streak.
11 12 13 |
# File 'lib/trophy_api_client/types/wrapped_streak.rb', line 11 def length @length end |
#period_end ⇒ String (readonly)
Returns The end date of the streak period.
17 18 19 |
# File 'lib/trophy_api_client/types/wrapped_streak.rb', line 17 def period_end @period_end end |
#period_start ⇒ String (readonly)
Returns The start date of the streak period.
15 16 17 |
# File 'lib/trophy_api_client/types/wrapped_streak.rb', line 15 def period_start @period_start end |
#started ⇒ String (readonly)
Returns The date the streak started.
19 20 21 |
# File 'lib/trophy_api_client/types/wrapped_streak.rb', line 19 def started @started end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::WrappedStreak
Deserialize a JSON object to an instance of WrappedStreak
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/trophy_api_client/types/wrapped_streak.rb', line 57 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) length = parsed_json["length"] frequency = parsed_json["frequency"] period_start = parsed_json["periodStart"] period_end = parsed_json["periodEnd"] started = parsed_json["started"] new( length: length, frequency: frequency, period_start: period_start, period_end: period_end, started: started, 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.
88 89 90 91 92 93 94 |
# File 'lib/trophy_api_client/types/wrapped_streak.rb', line 88 def self.validate_raw(obj:) obj.length.is_a?(Integer) != false || raise("Passed value for field obj.length is not the expected type, validation failed.") obj.frequency.is_a?(TrophyApiClient::StreakFrequency) != false || raise("Passed value for field obj.frequency is not the expected type, validation failed.") 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.started&.is_a?(String) != false || raise("Passed value for field obj.started is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of WrappedStreak to a JSON object
78 79 80 |
# File 'lib/trophy_api_client/types/wrapped_streak.rb', line 78 def to_json(*_args) @_field_set&.to_json end |