Class: Fleakr::Objects::AuthenticationToken

Inherits:
Object
  • Object
show all
Includes:
Support::Object
Defined in:
lib/fleakr/objects/authentication_token.rb

Overview

AuthenticationToken

This class represents an authentication token used for API calls that require authentication before they can be used

Attributes

value

The token value that is used in subsequent API calls

permissions

The permissions granted to this application (read / write / delete)

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Support::Object

included

Class Method Details

.from(thing, value) ⇒ Object

:nodoc:



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fleakr/objects/authentication_token.rb', line 42

def self.from(thing, value) # :nodoc:
  api_methods = {
    :mini_token => 'getFullToken',
    :auth_token => 'checkToken',
    :frob       => 'getToken'
  }

  method = "auth.#{api_methods[thing]}"

  parameters = {thing => value, :authenticate? => false}
  response = Fleakr::Api::MethodRequest.with_response!(method, parameters)

  self.new(response.body)
end

.from_auth_token(auth_token) ⇒ Object

Retrieve a full authentication token from the supplied auth_token string (e.g. 45-76598454353455)



33
34
35
# File 'lib/fleakr/objects/authentication_token.rb', line 33

def self.from_auth_token(auth_token)
  from :auth_token, auth_token
end

.from_frob(frob) ⇒ Object

Retrieve a full authentication token from the supplied frob



38
39
40
# File 'lib/fleakr/objects/authentication_token.rb', line 38

def self.from_frob(frob)
  from :frob, frob
end

.from_mini_token(mini_token) ⇒ Object

Retrieve a full authentication token from the supplied mini-token (e.g. 123-456-789)



26
27
28
# File 'lib/fleakr/objects/authentication_token.rb', line 26

def self.from_mini_token(mini_token)
  from :mini_token, mini_token
end

Instance Method Details

#userObject



57
58
59
# File 'lib/fleakr/objects/authentication_token.rb', line 57

def user
  User.find_by_id(user_id, :auth_token => value)
end