Class: TrophyApiClient::WrappedResponse
- Inherits:
-
Object
- Object
- TrophyApiClient::WrappedResponse
- Defined in:
- lib/trophy_api_client/types/wrapped_response.rb
Overview
A user’s year-in-review wrapped data including activity summaries, metrics,
points, achievements, streaks, and leaderboard rankings.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#activity ⇒ TrophyApiClient::WrappedActivity
readonly
The user’s activity data for the wrapped year.
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#user ⇒ TrophyApiClient::User
readonly
The user’s profile information.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::WrappedResponse
Deserialize a JSON object to an instance of WrappedResponse.
-
.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(user:, activity:, additional_properties: nil) ⇒ TrophyApiClient::WrappedResponse constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of WrappedResponse to a JSON object.
Constructor Details
#initialize(user:, activity:, additional_properties: nil) ⇒ TrophyApiClient::WrappedResponse
28 29 30 31 32 33 |
# File 'lib/trophy_api_client/types/wrapped_response.rb', line 28 def initialize(user:, activity:, additional_properties: nil) @user = user @activity = activity @additional_properties = additional_properties @_field_set = { "user": user, "activity": activity } end |
Instance Attribute Details
#activity ⇒ TrophyApiClient::WrappedActivity (readonly)
Returns The user’s activity data for the wrapped year.
15 16 17 |
# File 'lib/trophy_api_client/types/wrapped_response.rb', line 15 def activity @activity end |
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
17 18 19 |
# File 'lib/trophy_api_client/types/wrapped_response.rb', line 17 def additional_properties @additional_properties end |
#user ⇒ TrophyApiClient::User (readonly)
Returns The user’s profile information.
13 14 15 |
# File 'lib/trophy_api_client/types/wrapped_response.rb', line 13 def user @user end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::WrappedResponse
Deserialize a JSON object to an instance of WrappedResponse
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/trophy_api_client/types/wrapped_response.rb', line 39 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) if parsed_json["user"].nil? user = nil else user = parsed_json["user"].to_json user = TrophyApiClient::User.from_json(json_object: user) end if parsed_json["activity"].nil? activity = nil else activity = parsed_json["activity"].to_json activity = TrophyApiClient::WrappedActivity.from_json(json_object: activity) end new( user: user, activity: activity, 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.
74 75 76 77 |
# File 'lib/trophy_api_client/types/wrapped_response.rb', line 74 def self.validate_raw(obj:) TrophyApiClient::User.validate_raw(obj: obj.user) TrophyApiClient::WrappedActivity.validate_raw(obj: obj.activity) end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of WrappedResponse to a JSON object
64 65 66 |
# File 'lib/trophy_api_client/types/wrapped_response.rb', line 64 def to_json(*_args) @_field_set&.to_json end |