Sha256: e9aef53f5eb3b4716cb746df28b52b9083785a03f1c61511a620128499b9fa8a

Contents?: true

Size: 1.71 KB

Versions: 8

Compression:

Stored size: 1.71 KB

Contents

module Pubnub
  class Audit
    include Pubnub::Event
    include Pubnub::SingleEvent
    include Pubnub::Formatter
    include Pubnub::Validator
    include Pubnub::PAM

    def initialize(options, app)
      super
      @event = 'audit'
      @allow_multiple_channels = false
      @timestamp = current_time
    end

    def validate!
      raise ArgumentError.new(:object => self, :message => 'publish_key is required by Audit') unless @publish_key
      raise ArgumentError.new(:object => self, :message => 'Parameter secret_key is required by Audit') if !@secret_key || @secret_key == 0

      # check channel/channels
      raise ArgumentError.new(:object => self, :message => 'SetState requires :channel, :channels or :group argument') if @channel.blank? && @channel_group.blank?
      unless @channel.blank?
        raise ArgumentError.new(:object => self, :message => 'Invalid channel(s) format! Should be type of: String, Symbol, or Array of both') unless valid_channel?
      end

      unless @channel_group.blank?
        # check channel_group
        raise ArgumentError.new(:object => self, :message => 'Invalid channel group format! Should be type of: String, Symbol') unless [String, Symbol, NilClass].include?(@channel_group.class)

        # check channel_group
        # raise ArgumentError.new(:object => self, :message => ':group argument has to be in format "ns:cg", "ns:" or ":cg"') if @channel_group.count(':') != 1
      end
    end

    private

    def parameters(app, signature = false)
      { :timestamp => @timestamp }.merge(super(app, signature))
    end

    def path(app)
      '/' + [
          'v1',
          'auth',
          'audit',
          'sub-key',
          @subscribe_key
      ].join('/')
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pubnub-3.7.12 lib/pubnub/events/audit.rb
pubnub-3.7.11 lib/pubnub/events/audit.rb
pubnub-3.7.10 lib/pubnub/events/audit.rb
pubnub-3.7.9 lib/pubnub/events/audit.rb
pubnub-3.7.7 lib/pubnub/events/audit.rb
pubnub-3.7.5 lib/pubnub/events/audit.rb
pubnub-3.7.1 lib/pubnub/events/audit.rb
pubnub-3.7.0 lib/pubnub/events/audit.rb