Class: Lexer::Identity::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/lexer/identity/configuration.rb

Overview

Stores configuration details for communicating with the Lexer Identiy API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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_tokenObject

the API token provided by Lexer



13
14
15
# File 'lib/lexer/identity/configuration.rb', line 13

def api_token
  @api_token
end

#api_urlObject

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_tokenObject

the consumer token provided by Lexer



19
20
21
# File 'lib/lexer/identity/configuration.rb', line 19

def consumer_token
  @consumer_token
end

#contributor_tokenObject

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

#validateObject

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