Class: CommandTower::Messaging::Preferences::Update
- Inherits:
-
Object
- Object
- CommandTower::Messaging::Preferences::Update
- Defined in:
- app/services/command_tower/messaging/preferences/update.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(recipient_id:, notification_type_key:, preference_state:, platform_enabled_channels: []) ⇒ Update
constructor
A new instance of Update.
Constructor Details
#initialize(recipient_id:, notification_type_key:, preference_state:, platform_enabled_channels: []) ⇒ Update
Returns a new instance of Update.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/services/command_tower/messaging/preferences/update.rb', line 11 def initialize( recipient_id:, notification_type_key:, preference_state:, platform_enabled_channels: [] ) @recipient_id = recipient_id @notification_type_key = notification_type_key.to_s @preference_state = preference_state @platform_enabled_channels = Array(platform_enabled_channels).map(&:to_s).freeze end |
Class Method Details
.call ⇒ Object
7 8 9 |
# File 'app/services/command_tower/messaging/preferences/update.rb', line 7 def self.call(...) new(...).call end |
Instance Method Details
#call ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/services/command_tower/messaging/preferences/update.rb', line 23 def call declaration = lookup_declaration! validate_settings_visible!(declaration) validate_writable!(declaration) if reset_request? persist_reset! else candidate = build_candidate_state!(declaration) sparse = sparsify(declaration, candidate) persist_sparse!(sparse) end evaluation = Resolve.call( notification_type_key: @notification_type_key, recipient_id: @recipient_id, platform_enabled_channels: @platform_enabled_channels, ) build_notification_result(declaration, evaluation, recipient_ready_channel_keys) end |