class TableauServerClient::Token

Constants

SAFETY_BUFFER_MIN

Attributes

site_id[R]
token[R]
user_id[R]

Public Class Methods

new(site_id, user_id, token, lifetime, created_at = Time.now) click to toggle source
# File lib/tableau_server_client/token.rb, line 7
def initialize(site_id, user_id, token, lifetime, created_at = Time.now)
  @site_id = site_id
  @user_id = user_id
  @token = token
  @lifetime = lifetime
  @created_at = created_at
end
parse(xml, lifetime) click to toggle source
# File lib/tableau_server_client/token.rb, line 17
def self.parse(xml, lifetime)
  cred = Nokogiri::XML(xml).xpath("//xmlns:credentials")
  sid = cred.xpath("//xmlns:site")[0]['id']
  uid = cred.xpath("//xmlns:user")[0]['id']
  new(sid, uid, cred[0]['token'], lifetime)
end

Public Instance Methods

to_s() click to toggle source
# File lib/tableau_server_client/token.rb, line 30
def to_s
  @token
end
valid?() click to toggle source
# File lib/tableau_server_client/token.rb, line 26
def valid?
  Time.now < @created_at + (@lifetime + SAFETY_BUFFER_MIN) * 60
end