Class: Uservoice::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/uservoice/token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, api_key, data) ⇒ Token

Creates a sign-in token to authenticate user against the uservoice service. See ACCOUNT.uservoice.com/admin2/docs#/sso for data properties available.



18
19
20
21
22
23
24
25
# File 'lib/uservoice/token.rb', line 18

def initialize(key, api_key, data)
  data.merge!({:expires => (Time.now + 5 * 60).to_s})

  crypt_key = EzCrypto::Key.with_password(key, api_key)
  encrypted_data = crypt_key.encrypt(data.to_json)

  @data = CGI.escape(Base64.encode64(encrypted_data).gsub(/\n/, ''))
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



11
12
13
# File 'lib/uservoice/token.rb', line 11

def data
  @data
end

Instance Method Details

#to_sObject

:nodoc:



27
28
29
# File 'lib/uservoice/token.rb', line 27

def to_s #:nodoc:
  @data
end