Sha256: 7de77ecead909e14963444d9b30537f31561b141eb292b6523ee826dac2e67dd

Contents?: true

Size: 1.58 KB

Versions: 9

Compression:

Stored size: 1.58 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

9 entries across 9 versions & 1 rubygems

Version Path
datasift-3.7.2 examples/push_eg.rb
datasift-3.5.2 examples/push_eg.rb
datasift-3.5.1 examples/push_eg.rb
datasift-3.7.1 examples/push_eg.rb
datasift-3.7.0 examples/push_eg.rb
datasift-3.6.2 examples/push_eg.rb
datasift-3.6.1 examples/push_eg.rb
datasift-3.6.0 examples/push_eg.rb
datasift-3.5.0 examples/push_eg.rb