Class: Courier::Commons::NotificationPreferenceDetails
- Inherits:
-
Object
- Object
- Courier::Commons::NotificationPreferenceDetails
- Defined in:
- lib/trycourier/commons/types/notification_preference_details.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#channel_preferences ⇒ Object
readonly
Returns the value of attribute channel_preferences.
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Commons::NotificationPreferenceDetails
Deserialize a JSON object to an instance of NotificationPreferenceDetails.
-
.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(status:, rules: nil, channel_preferences: nil, additional_properties: nil) ⇒ Commons::NotificationPreferenceDetails constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of NotificationPreferenceDetails to a JSON object.
Constructor Details
#initialize(status:, rules: nil, channel_preferences: nil, additional_properties: nil) ⇒ Commons::NotificationPreferenceDetails
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/trycourier/commons/types/notification_preference_details.rb', line 18 def initialize(status:, rules: nil, channel_preferences: nil, additional_properties: nil) # @type [Commons::PreferenceStatus] @status = status # @type [Array<Commons::Rule>] @rules = rules # @type [Array<Commons::ChannelPreference>] @channel_preferences = channel_preferences # @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/commons/types/notification_preference_details.rb', line 11 def additional_properties @additional_properties end |
#channel_preferences ⇒ Object (readonly)
Returns the value of attribute channel_preferences.
11 12 13 |
# File 'lib/trycourier/commons/types/notification_preference_details.rb', line 11 def channel_preferences @channel_preferences end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
11 12 13 |
# File 'lib/trycourier/commons/types/notification_preference_details.rb', line 11 def rules @rules end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
11 12 13 |
# File 'lib/trycourier/commons/types/notification_preference_details.rb', line 11 def status @status end |
Class Method Details
.from_json(json_object:) ⇒ Commons::NotificationPreferenceDetails
Deserialize a JSON object to an instance of NotificationPreferenceDetails
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/trycourier/commons/types/notification_preference_details.rb', line 33 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) status = struct.status rules = parsed_json["rules"]&.map do |v| v = v.to_json Commons::Rule.from_json(json_object: v) end channel_preferences = parsed_json["channel_preferences"]&.map do |v| v = v.to_json Commons::ChannelPreference.from_json(json_object: v) end new(status: status, rules: rules, channel_preferences: channel_preferences, 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.
59 60 61 62 63 |
# File 'lib/trycourier/commons/types/notification_preference_details.rb', line 59 def self.validate_raw(obj:) obj.status.is_a?(Commons::PreferenceStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") obj.rules&.is_a?(Array) != false || raise("Passed value for field obj.rules is not the expected type, validation failed.") obj.channel_preferences&.is_a?(Array) != false || raise("Passed value for field obj.channel_preferences is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of NotificationPreferenceDetails to a JSON object
51 52 53 |
# File 'lib/trycourier/commons/types/notification_preference_details.rb', line 51 def to_json(*_args) { "status": @status, "rules": @rules, "channel_preferences": @channel_preferences }.to_json end |