Sha256: 4683e2e705c93c21813f3ead289b2afdeb66b4360e03f403f95ff095351da557
Contents?: true
Size: 1.02 KB
Versions: 2
Compression:
Stored size: 1.02 KB
Contents
module JeraPush::Services class SendToDevicesService < JeraPush::Services::BaseService def initialize(push:) super @push = push @device = @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(device, message_device) end end def send_push JeraPush::Services::SendPushService.new(push: @push, message: @message, message_device: @message_device ).call end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jera_push-2.1.3 | lib/jera_push/services/send_to_devices_service.rb |
jera_push-2.1.2 | lib/jera_push/services/send_to_devices_service.rb |