Class: CommandTower::Messaging::Preferences::Resolve
- Inherits:
-
Object
- Object
- CommandTower::Messaging::Preferences::Resolve
- Defined in:
- app/services/command_tower/messaging/preferences/resolve.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(notification_type_key:, recipient_id:, platform_enabled_channels: []) ⇒ Resolve
constructor
A new instance of Resolve.
Constructor Details
#initialize(notification_type_key:, recipient_id:, platform_enabled_channels: []) ⇒ Resolve
Returns a new instance of Resolve.
11 12 13 14 15 16 17 18 19 |
# File 'app/services/command_tower/messaging/preferences/resolve.rb', line 11 def initialize( notification_type_key:, recipient_id:, platform_enabled_channels: [] ) @notification_type_key = notification_type_key.to_s @recipient_id = recipient_id @platform_enabled_channels = platform_enabled_channels end |
Class Method Details
.call ⇒ Object
7 8 9 |
# File 'app/services/command_tower/messaging/preferences/resolve.rb', line 7 def self.call(...) new(...).call end |
Instance Method Details
#call ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/services/command_tower/messaging/preferences/resolve.rb', line 21 def call stored = Store.find( recipient_id: @recipient_id, notification_type_key: @notification_type_key, ) raw_override = stored&.to_raw_hash evaluation = Evaluator.call( notification_type_key: @notification_type_key, recipient_id: @recipient_id, preference_state: raw_override, platform_enabled_channels: @platform_enabled_channels, ) EvaluationResult.build( notification_type_key: evaluation.notification_type_key, recipient_id: evaluation.recipient_id, permitted_channels: evaluation.permitted_channels, inbox_permitted: evaluation.inbox_permitted, suppressed_destinations: evaluation.suppressed_destinations, mandatory: evaluation.mandatory, mandatory_enforced: evaluation.mandatory_enforced, stored_override_present: !stored.nil?, effective_preference_state: evaluation.effective_preference_state, ) end |