Sha256: 2816c7e13f7ed40642da26e3df75885db5b65914d4a40656c05775ed45d62585

Contents?: true

Size: 1.44 KB

Versions: 11

Compression:

Stored size: 1.44 KB

Contents

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

    def initialize(options, app)
      super
      @event = 'grant'
      @allow_multiple_channels = true

      @timestamp = current_time

      @write = options[:write]
      @read  = options[:read]
      @ttl   = options[:ttl]   || Pubnub::Configuration::DEFAULT_TTL
    end

    def validate!
      super

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

      raise ArgumentError.new(:object => self, :message => 'ttl parameter is too big, max value is: 525600') unless @ttl.to_i <= 525600 || @ttl.nil?
      raise ArgumentError.new(:object => self, :message => 'ttl parameter is too small, min value is: 1')  unless @ttl.to_i >= 1 || @ttl.nil?
    end

    private

    def parameters(app, signature = false)
      write = 0
      read  = 0

      {
          :timestamp => @timestamp,
          :w         => write,
          :r         => read,
          :ttl       => @ttl
      }.merge(super(app, signature))
    end

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

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pubnub-3.7.12 lib/pubnub/events/revoke.rb
pubnub-3.7.11 lib/pubnub/events/revoke.rb
pubnub-3.7.10 lib/pubnub/events/revoke.rb
pubnub-3.7.9 lib/pubnub/events/revoke.rb
pubnub-3.7.7 lib/pubnub/events/revoke.rb
pubnub-3.7.5 lib/pubnub/events/revoke.rb
pubnub-3.7.1 lib/pubnub/events/revoke.rb
pubnub-3.7.0 lib/pubnub/events/revoke.rb
pubnub-3.6.10 lib/pubnub/events/revoke.rb
pubnub-3.6.9 lib/pubnub/events/revoke.rb
pubnub-3.6.7 lib/pubnub/events/revoke.rb