Sha256: 7b28fa90a810caea904c0275d0d9df817af896c76ccf9479aa141c7459ed362d
Contents?: true
Size: 1.72 KB
Versions: 1
Compression:
Stored size: 1.72 KB
Contents
require './auth' class AccountIdentityTokenEg < DataSiftExample def initialize super @datasift = DataSift::Client.new(@config) run end def run begin puts "Create a new identity to create tokens for" identity = @datasift.account_identity.create( "Ruby Identity for Tokens", "active", false ) identity_id = identity[:data][:id] puts identity.to_json puts "\nCreate a Token for our Identity" puts @datasift.account_identity_token.create( identity_id, 'facebook', 'YOUR_TOKEN' ) puts "\nList all existing Tokens for this Identity" puts @datasift.account_identity_token.list( identity_id ).to_json puts "\nGet existing Token by Identity and Service" puts @datasift.account_identity_token.get( identity_id, 'facebook' ).to_json puts "\nUpdate a Token for a given Identity" puts @datasift.account_identity_token.update( identity_id, 'facebook', 'YOUR_NEW_TOKEN' ).to_json puts "\nDelete an Token for a given Identity and Service" puts @datasift.account_identity_token.delete( identity_id, 'facebook' ).to_json puts "\nCleanup and remove the Identity" @datasift.account_identity.delete(identity_id) 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 AccountIdentityTokenEg.new
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
datasift-3.2.0 | examples/account_identity_token_eg.rb |