Class: CommandTower::Messaging::Preferences::Catalog
- Inherits:
-
Object
- Object
- CommandTower::Messaging::Preferences::Catalog
- Defined in:
- app/services/command_tower/messaging/preferences/catalog.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(recipient_id:, platform_enabled_channels: []) ⇒ Catalog
constructor
A new instance of Catalog.
Constructor Details
#initialize(recipient_id:, platform_enabled_channels: []) ⇒ Catalog
Returns a new instance of Catalog.
11 12 13 14 |
# File 'app/services/command_tower/messaging/preferences/catalog.rb', line 11 def initialize(recipient_id:, platform_enabled_channels: []) @recipient_id = recipient_id @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/catalog.rb', line 7 def self.call(...) new(...).call end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 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 47 |
# File 'app/services/command_tower/messaging/preferences/catalog.rb', line 16 def call recipient_ready_keys = recipient_ready_channel_keys categories = [] NotificationTypes.catalog.each do |category| notifications = [] category.declarations.each do |declaration| next unless declaration.settings_visible evaluation = Resolve.call( notification_type_key: declaration.key, recipient_id: @recipient_id, platform_enabled_channels: @platform_enabled_channels, ) notifications << build_notification(declaration, evaluation, recipient_ready_keys) end next if notifications.empty? categories << ::CommandTower::Messaging::Preferences::CatalogCategoryResult.build( key: category.key, label: category.label, description: nil, order: category.order, notifications:, ) end ::CommandTower::Messaging::Preferences::CatalogResult.build(categories:) end |