Class: ResoTransport::Authentication::AuthStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/reso_transport/authentication/auth_strategy.rb

Overview

This base class defines the basic interface support by all client authentication implementations.

Direct Known Subclasses

FetchTokenAuth, StaticTokenAuth

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#accessObject (readonly)

Returns the value of attribute access.



5
6
7
# File 'lib/reso_transport/authentication/auth_strategy.rb', line 5

def access
  @access
end

Instance Method Details

#authenticateAccess

This method is abstract.

Perform requests to authenticate the client with the API

Returns The access token object.

Returns:

  • (Access)

    The access token object

Raises:

  • (NotImplementedError)


9
10
11
# File 'lib/reso_transport/authentication/auth_strategy.rb', line 9

def authenticate(*)
  raise NotImplementedError, 'Implement me!'
end

#ensure_valid_access!Object

Ensure that a valid access token is present or raise an exception

Raises:

  • (ResoWebApi::Errors::AccessDenied)

    If authentication fails



15
16
17
18
# File 'lib/reso_transport/authentication/auth_strategy.rb', line 15

def ensure_valid_access!
  @access = authenticate unless access && access.valid?
  access
end

#resetObject

Resets access



21
22
23
# File 'lib/reso_transport/authentication/auth_strategy.rb', line 21

def reset
  @access = nil
end