Sha256: e63e34aee1f59d667ad28ea19a03f9be2c577343480efc71299a83573d176798

Contents?: true

Size: 762 Bytes

Versions: 1

Compression:

Stored size: 762 Bytes

Contents

require 'forwardable'

module Moromi::Apns::Message
  class Base
    extend Forwardable

    attr_reader :parameter

    def_delegators :@parameter, :alert, :badge, :sound, :content_available, :mutable_content, :category, :priority

    # @param [Moromi::Apns::Parameter] parameter
    def initialize(parameter:)
      @parameter = parameter
    end

    def type
      self.class.name
    end

    def custom_data
      {type: type}.merge(@parameter.custom_data)
    end

    def serialize
      {
        type: type,
        parameter: @parameter.serialize
      }
    end

    # @param [Hash] params
    def self.unserialize(params)
      parameter = ::Moromi::Apns::Parameter.unserialize(params[:parameter])
      new(parameter: parameter)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
moromi-apns-0.6.0 lib/moromi/apns/message/base.rb