Sha256: 770977a93711dd9e73abeca80a1ef906104526ca0f0da2ee57c1a0690ae1a3ec

Contents?: true

Size: 765 Bytes

Versions: 9

Compression:

Stored size: 765 Bytes

Contents

require './auth'
class AccountEg < DataSiftExample
  def initialize
    super
    @datasift = DataSift::Client.new(@config)
    run
  end

  def run
    begin
      puts "Get account usage for the default period"
      puts @datasift.account.usage[:data].to_json

      puts "\nGet account usage for the past month"
      puts @datasift.account.usage('monthly')[:data].to_json

    rescue DataSiftError => dse
      puts dse.message
      # Then match specific error to take action;
      #   All errors thrown by the client extend DataSiftError
      case dse
        when ConnectionError
          # some connection error
        when AuthError
        when BadRequestError
        else
          # do something else...
      end
    end
  end
end

AccountEg.new

Version data entries

9 entries across 9 versions & 1 rubygems

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