Sha256: b6462c8e9968d7cc3a4ac53c22be9b65c9e0c509761792b5ca1dda1f944d1b93
Contents?: true
Size: 1023 Bytes
Versions: 1
Compression:
Stored size: 1023 Bytes
Contents
module JeraPush::Services class SendToDevicesService < JeraPush::Services::BaseService def initialize(push:) super @push = push @devices = @push.devices end def call validate_device return @errors if @errors.present? create_message send_push_to_devices @message end private def validate_device @errors.add(:base, message: I18n.t('jera_push.services.errors.not_found.device')) if @devices.empty? end def create_message @message = JeraPush::Message.create(title: @push.notification.title, body: @push.notification.body, data: @push.data) end def send_push_to_devices @devices.each do |device| @message_device = @message.message_devices.create(device: device) @push.device = device send_push end end def send_push JeraPush::Services::SendPushService.new(push: @push, message: @message, message_device: @message_device ).call end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jera_push-2.1.4 | lib/jera_push/services/send_to_devices_service.rb |