Class: ResoWebApi::Authentication::AuthStrategy

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

Overview

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

Direct Known Subclasses

TokenAuth

Constant Summary

Constants inherited from BaseClient

BaseClient::USER_AGENT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseClient

#connection, #headers

Instance Attribute Details

#accessObject (readonly)

Returns the value of attribute access


5
6
7
# File 'lib/reso_web_api/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_web_api/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:


15
16
17
18
# File 'lib/reso_web_api/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_web_api/authentication/auth_strategy.rb', line 21

def reset
  @access = nil
end