Class: FlexmlsApi::Authentication::BaseAuth
- Inherits:
-
Object
- Object
- FlexmlsApi::Authentication::BaseAuth
- Defined in:
- lib/flexmls_api/authentication/base_auth.rb
Overview
Authentication Base
This base class defines the basic interface supported by all client authentication implementations.
Instance Attribute Summary collapse
-
#session ⇒ Object
Returns the value of attribute session.
Instance Method Summary collapse
-
#authenticate ⇒ Object
Perform requests to authenticate the client with the API.
-
#authenticated? ⇒ Boolean
Called prior to running authenticate (except in case of api authentication errors).
-
#build_url_parameters(parameters = {}) ⇒ Object
Format a hash as request parameters.
-
#initialize(client) ⇒ BaseAuth
constructor
All ihheriting classes should accept the flexmls_api client as a part of initialization.
-
#logout ⇒ Object
Terminate the active session.
-
#request(method, path, body, options) ⇒ Object
Perform an HTTP request (no data).
Constructor Details
#initialize(client) ⇒ BaseAuth
All ihheriting classes should accept the flexmls_api client as a part of initialization
10 11 12 |
# File 'lib/flexmls_api/authentication/base_auth.rb', line 10 def initialize(client) @client = client end |
Instance Attribute Details
#session ⇒ Object
Returns the value of attribute session.
8 9 10 |
# File 'lib/flexmls_api/authentication/base_auth.rb', line 8 def session @session end |
Instance Method Details
#authenticate ⇒ Object
Perform requests to authenticate the client with the API
15 16 17 |
# File 'lib/flexmls_api/authentication/base_auth.rb', line 15 def authenticate raise "Implement me!" end |
#authenticated? ⇒ Boolean
Called prior to running authenticate (except in case of api authentication errors)
20 21 22 |
# File 'lib/flexmls_api/authentication/base_auth.rb', line 20 def authenticated? !(session.nil? || session.expired?) end |
#build_url_parameters(parameters = {}) ⇒ Object
Format a hash as request parameters
:returns:
Stringized form of the parameters as needed for an HTTP request
38 39 40 41 42 43 44 |
# File 'lib/flexmls_api/authentication/base_auth.rb', line 38 def build_url_parameters(parameters={}) array = parameters.map do |key,value| escaped_value = CGI.escape("#{value}") "#{key}=#{escaped_value}" end array.join "&" end |
#logout ⇒ Object
Terminate the active session
25 26 27 |
# File 'lib/flexmls_api/authentication/base_auth.rb', line 25 def logout raise "Implement me!" end |
#request(method, path, body, options) ⇒ Object
Perform an HTTP request (no data)
30 31 32 |
# File 'lib/flexmls_api/authentication/base_auth.rb', line 30 def request(method, path, body, ) raise "Implement me!" end |