Class: Lexer::Identity::Configuration
- Inherits:
-
Object
- Object
- Lexer::Identity::Configuration
- Defined in:
- lib/lexer/identity/configuration.rb
Overview
Stores configuration details for communicating with the Lexer Identiy API.
Instance Attribute Summary collapse
-
#api_token ⇒ Object
the API token provided by Lexer.
-
#api_url ⇒ Object
The full path to the API and endpoint.
-
#consumer_token ⇒ Object
the consumer token provided by Lexer.
-
#contributor_token ⇒ Object
the contributor token provided by Lexer.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
Creates the configuration instance and defines default values.
-
#validate ⇒ Object
validates the current configuration, raising exceptions when invalid.
Constructor Details
#initialize ⇒ Configuration
Creates the configuration instance and defines default values
22 23 24 25 26 27 |
# File 'lib/lexer/identity/configuration.rb', line 22 def initialize @api_url = 'https://identity.lexer.io/identity' @api_token = nil @contributor_token = nil @consumer_token = nil end |
Instance Attribute Details
#api_token ⇒ Object
the API token provided by Lexer
13 14 15 |
# File 'lib/lexer/identity/configuration.rb', line 13 def api_token @api_token end |
#api_url ⇒ Object
The full path to the API and endpoint
10 11 12 |
# File 'lib/lexer/identity/configuration.rb', line 10 def api_url @api_url end |
#consumer_token ⇒ Object
the consumer token provided by Lexer
19 20 21 |
# File 'lib/lexer/identity/configuration.rb', line 19 def consumer_token @consumer_token end |
#contributor_token ⇒ Object
the contributor token provided by Lexer
16 17 18 |
# File 'lib/lexer/identity/configuration.rb', line 16 def contributor_token @contributor_token end |
Instance Method Details
#validate ⇒ Object
validates the current configuration, raising exceptions when invalid
30 31 32 33 34 |
# File 'lib/lexer/identity/configuration.rb', line 30 def validate fail Lexer::Identity::ConfigurationError, 'An API token is required' if @api_token.nil? fail Lexer::Identity::ConfigurationError, 'A Contributor or Consumer token is required' if @contributor_token.nil? && @consumer_token.nil? fail Lexer::Identity::ConfigurationError, 'Contributor and Consumer tokens are not interchangable' if @contributor_token == @consumer_token end |