Class: TrophyApiClient::UserPreferencesResponse
- Inherits:
-
Object
- Object
- TrophyApiClient::UserPreferencesResponse
- Defined in:
- lib/trophy_api_client/types/user_preferences_response.rb
Overview
A user’s preferences.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #notifications ⇒ TrophyApiClient::NotificationPreferences readonly
- #streak ⇒ TrophyApiClient::StreakPreferences readonly
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::UserPreferencesResponse
Deserialize a JSON object to an instance of UserPreferencesResponse.
-
.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(notifications:, streak: OMIT, additional_properties: nil) ⇒ TrophyApiClient::UserPreferencesResponse constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of UserPreferencesResponse to a JSON object.
Constructor Details
#initialize(notifications:, streak: OMIT, additional_properties: nil) ⇒ TrophyApiClient::UserPreferencesResponse
27 28 29 30 31 32 33 34 |
# File 'lib/trophy_api_client/types/user_preferences_response.rb', line 27 def initialize(notifications:, streak: OMIT, additional_properties: nil) @notifications = notifications @streak = streak if streak != OMIT @additional_properties = additional_properties @_field_set = { "notifications": notifications, "streak": streak }.reject do |_k, v| v == OMIT end 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/user_preferences_response.rb', line 16 def additional_properties @additional_properties end |
#notifications ⇒ TrophyApiClient::NotificationPreferences (readonly)
12 13 14 |
# File 'lib/trophy_api_client/types/user_preferences_response.rb', line 12 def notifications @notifications end |
#streak ⇒ TrophyApiClient::StreakPreferences (readonly)
14 15 16 |
# File 'lib/trophy_api_client/types/user_preferences_response.rb', line 14 def streak @streak end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::UserPreferencesResponse
Deserialize a JSON object to an instance of UserPreferencesResponse
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/trophy_api_client/types/user_preferences_response.rb', line 40 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) if parsed_json["notifications"].nil? notifications = nil else notifications = parsed_json["notifications"].to_json notifications = TrophyApiClient::NotificationPreferences.from_json(json_object: notifications) end if parsed_json["streak"].nil? streak = nil else streak = parsed_json["streak"].to_json streak = TrophyApiClient::StreakPreferences.from_json(json_object: streak) end new( notifications: notifications, streak: streak, 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.
75 76 77 78 |
# File 'lib/trophy_api_client/types/user_preferences_response.rb', line 75 def self.validate_raw(obj:) TrophyApiClient::NotificationPreferences.validate_raw(obj: obj.notifications) obj.streak.nil? || TrophyApiClient::StreakPreferences.validate_raw(obj: obj.streak) end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of UserPreferencesResponse to a JSON object
65 66 67 |
# File 'lib/trophy_api_client/types/user_preferences_response.rb', line 65 def to_json(*_args) @_field_set&.to_json end |