Sha256: ee17f9c1b752c16df0067ae2077507a9eb82c665855cae5513d8a4b57fe0ab3f

Contents?: true

Size: 1.49 KB

Versions: 8

Compression:

Stored size: 1.49 KB

Contents

# This script resumes Push subscriptions in your account.
#
# NB: Most of the error handling (exception catching) has been removed for
# the sake of simplicity. Nearly everything in this library may throw
# exceptions, and production code should catch them. See the documentation
# for full details.
#

# Include the shared Env class
require File.dirname(__FILE__) + '/env'

# Create the env object. This reads the command line arguments, creates the
# user object, and provides access to both along with helper functions.
env = Env.new()

# Make sure we have 0 or 1 arguments
abort('Please specify one or more subscription IDs') unless env.args.size() < 2

begin
	# Get the log
	arg_count = env.args.size()
	if arg_count == 0
		log = env.user.getPushSubscriptionLog()
	else
		subscription_id = env.args[0]
		log = env.user.getPushSubscriptionLog(subscription_id)
	end

	# Make sure we have some log entries
	abort('No log entries found.') unless log['count'] > 0

	# Display the log entries in reverse order
	log['log_entries'].reverse().each do |log_entry|
		print (DateTime.strptime(String(log_entry['request_time']), '%s')).strftime('%Y-%m-%d %H:%M:%S') + ' '
		print '[' + log_entry['subscription_id'] + '] ' if arg_count == 0
		print 'Success ' if log_entry['success']
		puts log_entry['message']
	end
rescue DataSift::DataSiftError => err
	puts 'ERR: [' + err.class.name + '] ' + err.message
end

if env.user.rate_limit_remaining != -1
	puts 'Rate limit remainining: ' + String(env.user.rate_limit_remaining)
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
datasift-2.1.1 examples/push/view-log.rb
datasift-2.1.0 examples/push/view-log.rb
datasift-2.1.0.beta examples/push/view-log.rb
datasift-2.0.4 examples/push/view-log.rb
datasift-2.0.3 examples/push/view-log.rb
datasift-2.0.2 examples/push/view-log.rb
datasift-2.0.1 examples/push/view-log.rb
datasift-2.0.0 examples/push/view-log.rb