Class: CommandTower::Messaging::Contract::Internal::Finder
- Inherits:
-
Object
- Object
- CommandTower::Messaging::Contract::Internal::Finder
- Defined in:
- app/services/command_tower/messaging/contract/internal/finder.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(request) ⇒ Finder
constructor
A new instance of Finder.
Constructor Details
#initialize(request) ⇒ Finder
Returns a new instance of Finder.
12 13 14 |
# File 'app/services/command_tower/messaging/contract/internal/finder.rb', line 12 def initialize(request) @request = request end |
Class Method Details
.call(request) ⇒ Object
8 9 10 |
# File 'app/services/command_tower/messaging/contract/internal/finder.rb', line 8 def self.call(request) new(request).call end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/services/command_tower/messaging/contract/internal/finder.rb', line 16 def call validate_request! scope = Messaging::Communication.includes( :destination_plan, :inbox_item, channel_deliveries: :delivery_attempts, ) scope = scope.where(user_id: request.recipient_id) unless request.recipient_id.nil? communication = scope.find_by(id: request.communication_id) raise Contract::NotFoundError, "Communication not found" if communication.nil? Mappers::CommunicationMapper.to_result(communication) end |