Class: Courier::Users::Preferences::UserPreferencesGetResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/users/preferences/types/user_preferences_get_response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(topic:, additional_properties: nil) ⇒ Users::Preferences::UserPreferencesGetResponse

Parameters:



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_propertiesObject (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

#topicObject (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

Parameters:

  • json_object (JSON)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (JSON)


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