Class: Uservoice::Token
- Inherits:
-
Object
- Object
- Uservoice::Token
- Defined in:
- lib/uservoice/token.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(key, api_key, data) ⇒ Token
constructor
Creates a sign-in token to authenticate user against the uservoice service.
-
#to_s ⇒ Object
:nodoc:.
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
#data ⇒ Object (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_s ⇒ Object
:nodoc:
27 28 29 |
# File 'lib/uservoice/token.rb', line 27 def to_s #:nodoc: @data end |