Class: Courier::Users::Preferences::UserPreferencesGetResponse
- Inherits:
-
Object
- Object
- Courier::Users::Preferences::UserPreferencesGetResponse
- Defined in:
- lib/trycourier/users/preferences/types/user_preferences_get_response.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#topic ⇒ Object
readonly
Returns the value of attribute topic.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Users::Preferences::UserPreferencesGetResponse
Deserialize a JSON object to an instance of UserPreferencesGetResponse.
-
.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(topic:, additional_properties: nil) ⇒ Users::Preferences::UserPreferencesGetResponse constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of UserPreferencesGetResponse to a JSON object.
Constructor Details
#initialize(topic:, additional_properties: nil) ⇒ Users::Preferences::UserPreferencesGetResponse
15 16 17 18 19 20 |
# File 'lib/trycourier/users/preferences/types/user_preferences_get_response.rb', line 15 def initialize(topic:, additional_properties: nil) # @type [Users::Preferences::TopicPreference] @topic = topic # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end |
Instance Attribute Details
#additional_properties ⇒ Object (readonly)
Returns the value of attribute additional_properties.
10 11 12 |
# File 'lib/trycourier/users/preferences/types/user_preferences_get_response.rb', line 10 def additional_properties @additional_properties end |
#topic ⇒ Object (readonly)
Returns the value of attribute topic.
10 11 12 |
# File 'lib/trycourier/users/preferences/types/user_preferences_get_response.rb', line 10 def topic @topic end |
Class Method Details
.from_json(json_object:) ⇒ Users::Preferences::UserPreferencesGetResponse
Deserialize a JSON object to an instance of UserPreferencesGetResponse
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/trycourier/users/preferences/types/user_preferences_get_response.rb', line 26 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) if parsed_json["topic"].nil? topic = nil else topic = parsed_json["topic"].to_json topic = Users::Preferences::TopicPreference.from_json(json_object: topic) end new(topic: topic, 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.
49 50 51 |
# File 'lib/trycourier/users/preferences/types/user_preferences_get_response.rb', line 49 def self.validate_raw(obj:) Users::Preferences::TopicPreference.validate_raw(obj: obj.topic) end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of UserPreferencesGetResponse to a JSON object
41 42 43 |
# File 'lib/trycourier/users/preferences/types/user_preferences_get_response.rb', line 41 def to_json(*_args) { "topic": @topic }.to_json end |