Class: Courier::Users::Preferences::TopicPreference
- Inherits:
-
Object
- Object
- Courier::Users::Preferences::TopicPreference
- Defined in:
- lib/trycourier/users/preferences/types/topic_preference.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#custom_routing ⇒ Object
readonly
Returns the value of attribute custom_routing.
-
#default_status ⇒ Object
readonly
Returns the value of attribute default_status.
-
#has_custom_routing ⇒ Object
readonly
Returns the value of attribute has_custom_routing.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#topic_id ⇒ Object
readonly
Returns the value of attribute topic_id.
-
#topic_name ⇒ Object
readonly
Returns the value of attribute topic_name.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Users::Preferences::TopicPreference
Deserialize a JSON object to an instance of TopicPreference.
-
.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(default_status:, status:, topic_id:, topic_name:, custom_routing: nil, has_custom_routing: nil, additional_properties: nil) ⇒ Users::Preferences::TopicPreference constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of TopicPreference to a JSON object.
Constructor Details
#initialize(default_status:, status:, topic_id:, topic_name:, custom_routing: nil, has_custom_routing: nil, additional_properties: nil) ⇒ Users::Preferences::TopicPreference
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/trycourier/users/preferences/types/topic_preference.rb', line 22 def initialize(default_status:, status:, topic_id:, topic_name:, custom_routing: nil, has_custom_routing: nil, additional_properties: nil) # @type [Array<Commons::ChannelClassification>] The Channels a user has chosen to receive notifications through for this topic @custom_routing = custom_routing # @type [Commons::PreferenceStatus] @default_status = default_status # @type [Boolean] @has_custom_routing = has_custom_routing # @type [Commons::PreferenceStatus] @status = status # @type [String] @topic_id = topic_id # @type [String] @topic_name = topic_name # @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.
11 12 13 |
# File 'lib/trycourier/users/preferences/types/topic_preference.rb', line 11 def additional_properties @additional_properties end |
#custom_routing ⇒ Object (readonly)
Returns the value of attribute custom_routing.
11 12 13 |
# File 'lib/trycourier/users/preferences/types/topic_preference.rb', line 11 def custom_routing @custom_routing end |
#default_status ⇒ Object (readonly)
Returns the value of attribute default_status.
11 12 13 |
# File 'lib/trycourier/users/preferences/types/topic_preference.rb', line 11 def default_status @default_status end |
#has_custom_routing ⇒ Object (readonly)
Returns the value of attribute has_custom_routing.
11 12 13 |
# File 'lib/trycourier/users/preferences/types/topic_preference.rb', line 11 def has_custom_routing @has_custom_routing end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
11 12 13 |
# File 'lib/trycourier/users/preferences/types/topic_preference.rb', line 11 def status @status end |
#topic_id ⇒ Object (readonly)
Returns the value of attribute topic_id.
11 12 13 |
# File 'lib/trycourier/users/preferences/types/topic_preference.rb', line 11 def topic_id @topic_id end |
#topic_name ⇒ Object (readonly)
Returns the value of attribute topic_name.
11 12 13 |
# File 'lib/trycourier/users/preferences/types/topic_preference.rb', line 11 def topic_name @topic_name end |
Class Method Details
.from_json(json_object:) ⇒ Users::Preferences::TopicPreference
Deserialize a JSON object to an instance of TopicPreference
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/trycourier/users/preferences/types/topic_preference.rb', line 44 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) JSON.parse(json_object) custom_routing = struct.custom_routing default_status = struct.default_status has_custom_routing = struct.has_custom_routing status = struct.status topic_id = struct.topic_id topic_name = struct.topic_name new(custom_routing: custom_routing, default_status: default_status, has_custom_routing: has_custom_routing, status: status, topic_id: topic_id, topic_name: topic_name, 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 79 80 81 82 |
# File 'lib/trycourier/users/preferences/types/topic_preference.rb', line 75 def self.validate_raw(obj:) obj.custom_routing&.is_a?(Array) != false || raise("Passed value for field obj.custom_routing is not the expected type, validation failed.") obj.default_status.is_a?(Commons::PreferenceStatus) != false || raise("Passed value for field obj.default_status is not the expected type, validation failed.") obj.has_custom_routing&.is_a?(Boolean) != false || raise("Passed value for field obj.has_custom_routing is not the expected type, validation failed.") obj.status.is_a?(Commons::PreferenceStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") obj.topic_id.is_a?(String) != false || raise("Passed value for field obj.topic_id is not the expected type, validation failed.") obj.topic_name.is_a?(String) != false || raise("Passed value for field obj.topic_name is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of TopicPreference to a JSON object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/trycourier/users/preferences/types/topic_preference.rb', line 60 def to_json(*_args) { "custom_routing": @custom_routing, "default_status": @default_status, "has_custom_routing": @has_custom_routing, "status": @status, "topic_id": @topic_id, "topic_name": @topic_name }.to_json end |