Sha256: 9df6ee163c63ca35cdf7f59a7227358be800609d1b737211e4045521609de622

Contents?: true

Size: 1.57 KB

Versions: 11

Compression:

Stored size: 1.57 KB

Contents

require './auth'
class PushApi < DataSiftExample
  def initialize
    super
    run
  end

  def run
    begin
      puts 'Creating Push subscription'
      subscription = @datasift.push.create @params.merge(hash: '54dbfc8464258de162b7f1a057e630c5', name: 'Ruby Client Example')

      subscription_id = subscription[:data][:id]
      puts "\nPush subscription created! Push Subscription ID #{subscription_id}"

      puts "\nGetting subscription info"
      # Get details for a subscription. Also available are
      # push.[get, get_by_hash,get_by_historics_id]
      puts @datasift.push.get_by_subscription subscription_id

      puts "\nPausing Push subscription"
      # Push subscriptions can be paused for up to an hour
      @datasift.push.pause subscription_id

      puts "\nResuming Push subscription"
      # Push subscriptions must be resumed to continue delivering data
      @datasift.push.resume subscription_id

      puts "\nGetting subscription logs"
      # Get logs for a subscription. Also available is
      # push.log to get logs for all subscriptions
      puts @datasift.push.log_for subscription_id

      puts "\nStopping Push subscription"
      # Push subscriptions can be stopped. Once stopped, a
      # subscription can not be resumed
      @datasift.push.stop subscription_id

      puts "\nDeleting Push subscription"
      # Push subscriptions can be deleted. On delete, any undelivered
      # data is dropped. A delete is permenent.
      @datasift.push.delete subscription_id

    rescue DataSiftError => dse
      puts dse.message
    end
  end
end

PushApi.new()

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
datasift-3.4.0 examples/push_eg.rb
datasift-3.3.0 examples/push_eg.rb
datasift-3.2.0 examples/push_eg.rb
datasift-3.1.5 examples/push_eg.rb
datasift-3.1.4 examples/push_eg.rb
datasift-3.1.3 examples/push_eg.rb
datasift-3.1.2 examples/push_eg.rb
datasift-3.1.1 examples/push_eg.rb
datasift-3.1.0 examples/push_eg.rb
datasift-3.0.1 examples/push_eg.rb
datasift-3.0.0 examples/push_eg.rb