lib/ultradns/api/authentication.rb
# Try a request and if there is an authentication failure, retry after
# refreshing the tokens.
#
# yields to the block with the class so that HTTParty class methods can be used.
# Example:  with_auth_retry {|c| c.get '/' }
Try a request and if there is an authentication failure, retry after
refreshing the tokens.

yields to the block with the class so that HTTParty class methods can be used.
Example:  with_auth_retry {|c| c.get '/' }
Try a request and if there is an authentication failure retry after refreshing the tokens . yields to the block with the class so that HTTParty class methods can be used . Example : with_auth_retry { |c| c . get ' / ' }
def with_auth_retry(&block)
    retries = 3
    response = nil
    while retries > 0
      response = yield(self.class)
      if auth_failure?(response)
        refresh
        retries = retries - 1
        logger.info "authentication failure, retrying..." if retries > 0
      else
        retries = 0
      end
    end
    response
  end
def with_auth_retry ( & block ) retries = 3 response = nil while retries > 0 response = yield ( self . class ) if auth_failure? ( response ) refresh retries = retries - 1 logger . info "authentication failure, retrying..." if retries > 0 else retries = 0 end end response end
Try a request and if there is an authentication failure, retry after
refreshing the tokens.
Try a request and if there is an authentication failure retry after refreshing the tokens .
block