Sha256: 7de40b9cff544ca7dddf13378fd95815bb2a8cfaaadfa888ce64c19b96848a2e

Contents?: true

Size: 760 Bytes

Versions: 4

Compression:

Stored size: 760 Bytes

Contents

module JeraPush::Services
  class SendToTopicService < JeraPush::Services::BaseService
    def initialize(title:, body:, topic:)
      super
      @title = title
      @body = body
      @topic = topic
    end

    def call
      create_message
      send_topic
      update_message

      @message
    end

    private

    def create_message
      @message = JeraPush::Message.create(title: @title, body: @body, kind: :topic)
    end

    def send_topic
      @response = @firebase.send_message_to_topic(message: @message, topic: @topic)
    end

    def update_message
      @message.update(
        multicast_id: @response["multicast_id"],
        success_count: @response["success"],
        failure_count: @response["failure"]
      )
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jera_push-2.1.4 lib/jera_push/services/send_to_topic_service.rb
jera_push-2.1.3 lib/jera_push/services/send_to_topic_service.rb
jera_push-2.1.2 lib/jera_push/services/send_to_topic_service.rb
jera_push-2.0.0 lib/jera_push/services/send_to_topic_service.rb