Class: TrophyApiClient::WrappedActivity
- Inherits:
-
Object
- Object
- TrophyApiClient::WrappedActivity
- Defined in:
- lib/trophy_api_client/types/wrapped_activity.rb
Overview
The user’s activity summary for the wrapped year.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#days_active ⇒ Integer
readonly
The number of days the user was active during the year.
-
#entire_year ⇒ TrophyApiClient::WrappedEntireYear
readonly
Data about the user’s activity for the entire year.
-
#months_active ⇒ Integer
readonly
The number of months the user was active during the year.
-
#most_active_day ⇒ TrophyApiClient::WrappedMostActiveDay
readonly
Data about the user’s most active day.
-
#most_active_month ⇒ TrophyApiClient::WrappedMostActiveMonth
readonly
Data about the user’s most active month.
-
#most_active_week ⇒ TrophyApiClient::WrappedMostActiveWeek
readonly
Data about the user’s most active week.
-
#weeks_active ⇒ Integer
readonly
The number of weeks the user was active during the year.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::WrappedActivity
Deserialize a JSON object to an instance of WrappedActivity.
-
.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(days_active:, weeks_active:, months_active:, most_active_day:, most_active_week:, most_active_month:, entire_year:, additional_properties: nil) ⇒ TrophyApiClient::WrappedActivity constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of WrappedActivity to a JSON object.
Constructor Details
#initialize(days_active:, weeks_active:, months_active:, most_active_day:, most_active_week:, most_active_month:, entire_year:, additional_properties: nil) ⇒ TrophyApiClient::WrappedActivity
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/trophy_api_client/types/wrapped_activity.rb', line 44 def initialize(days_active:, weeks_active:, months_active:, most_active_day:, most_active_week:, most_active_month:, entire_year:, additional_properties: nil) @days_active = days_active @weeks_active = weeks_active @months_active = months_active @most_active_day = most_active_day @most_active_week = most_active_week @most_active_month = most_active_month @entire_year = entire_year @additional_properties = additional_properties @_field_set = { "daysActive": days_active, "weeksActive": weeks_active, "monthsActive": months_active, "mostActiveDay": most_active_day, "mostActiveWeek": most_active_week, "mostActiveMonth": most_active_month, "entireYear": entire_year } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
28 29 30 |
# File 'lib/trophy_api_client/types/wrapped_activity.rb', line 28 def additional_properties @additional_properties end |
#days_active ⇒ Integer (readonly)
Returns The number of days the user was active during the year.
14 15 16 |
# File 'lib/trophy_api_client/types/wrapped_activity.rb', line 14 def days_active @days_active end |
#entire_year ⇒ TrophyApiClient::WrappedEntireYear (readonly)
Returns Data about the user’s activity for the entire year.
26 27 28 |
# File 'lib/trophy_api_client/types/wrapped_activity.rb', line 26 def entire_year @entire_year end |
#months_active ⇒ Integer (readonly)
Returns The number of months the user was active during the year.
18 19 20 |
# File 'lib/trophy_api_client/types/wrapped_activity.rb', line 18 def months_active @months_active end |
#most_active_day ⇒ TrophyApiClient::WrappedMostActiveDay (readonly)
Returns Data about the user’s most active day.
20 21 22 |
# File 'lib/trophy_api_client/types/wrapped_activity.rb', line 20 def most_active_day @most_active_day end |
#most_active_month ⇒ TrophyApiClient::WrappedMostActiveMonth (readonly)
Returns Data about the user’s most active month.
24 25 26 |
# File 'lib/trophy_api_client/types/wrapped_activity.rb', line 24 def most_active_month @most_active_month end |
#most_active_week ⇒ TrophyApiClient::WrappedMostActiveWeek (readonly)
Returns Data about the user’s most active week.
22 23 24 |
# File 'lib/trophy_api_client/types/wrapped_activity.rb', line 22 def most_active_week @most_active_week end |
#weeks_active ⇒ Integer (readonly)
Returns The number of weeks the user was active during the year.
16 17 18 |
# File 'lib/trophy_api_client/types/wrapped_activity.rb', line 16 def weeks_active @weeks_active end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::WrappedActivity
Deserialize a JSON object to an instance of WrappedActivity
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/trophy_api_client/types/wrapped_activity.rb', line 69 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) days_active = parsed_json["daysActive"] weeks_active = parsed_json["weeksActive"] months_active = parsed_json["monthsActive"] if parsed_json["mostActiveDay"].nil? most_active_day = nil else most_active_day = parsed_json["mostActiveDay"].to_json most_active_day = TrophyApiClient::WrappedMostActiveDay.from_json(json_object: most_active_day) end if parsed_json["mostActiveWeek"].nil? most_active_week = nil else most_active_week = parsed_json["mostActiveWeek"].to_json most_active_week = TrophyApiClient::WrappedMostActiveWeek.from_json(json_object: most_active_week) end if parsed_json["mostActiveMonth"].nil? most_active_month = nil else most_active_month = parsed_json["mostActiveMonth"].to_json most_active_month = TrophyApiClient::WrappedMostActiveMonth.from_json(json_object: most_active_month) end if parsed_json["entireYear"].nil? entire_year = nil else entire_year = parsed_json["entireYear"].to_json entire_year = TrophyApiClient::WrappedEntireYear.from_json(json_object: entire_year) end new( days_active: days_active, weeks_active: weeks_active, months_active: months_active, most_active_day: most_active_day, most_active_week: most_active_week, most_active_month: most_active_month, entire_year: entire_year, 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.
124 125 126 127 128 129 130 131 132 |
# File 'lib/trophy_api_client/types/wrapped_activity.rb', line 124 def self.validate_raw(obj:) obj.days_active.is_a?(Integer) != false || raise("Passed value for field obj.days_active is not the expected type, validation failed.") obj.weeks_active.is_a?(Integer) != false || raise("Passed value for field obj.weeks_active is not the expected type, validation failed.") obj.months_active.is_a?(Integer) != false || raise("Passed value for field obj.months_active is not the expected type, validation failed.") TrophyApiClient::WrappedMostActiveDay.validate_raw(obj: obj.most_active_day) TrophyApiClient::WrappedMostActiveWeek.validate_raw(obj: obj.most_active_week) TrophyApiClient::WrappedMostActiveMonth.validate_raw(obj: obj.most_active_month) TrophyApiClient::WrappedEntireYear.validate_raw(obj: obj.entire_year) end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of WrappedActivity to a JSON object
114 115 116 |
# File 'lib/trophy_api_client/types/wrapped_activity.rb', line 114 def to_json(*_args) @_field_set&.to_json end |