Module: Lexer::Identity
- Defined in:
- lib/lexer/identity.rb,
lib/lexer/identity/api.rb,
lib/lexer/identity/version.rb,
lib/lexer/identity/configuration.rb,
lib/lexer/identity/enriched_result.rb
Overview
:nordoc:
Defined Under Namespace
Classes: AuthenticationError, BadRequestError, Configuration, ConfigurationError, EnrichedResult, Error, HttpError, NotFoundError
Constant Summary collapse
- VERSION =
'0.1.0'
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
-
.logger ⇒ Object
Defines the modules logger Accessible via:.
Class Method Summary collapse
-
.configure {|configuration| ... } ⇒ Object
Creates or uses active configutation See
Lexer::Identity.configuration
for options. -
.enrich(links: {}, attributes: {}) ⇒ Object
The backbone of the Identity API.
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
62 63 64 |
# File 'lib/lexer/identity.rb', line 62 def configuration @configuration end |
Class Method Details
.configure {|configuration| ... } ⇒ Object
Creates or uses active configutation See Lexer::Identity.configuration
for options
81 82 83 84 85 86 |
# File 'lib/lexer/identity.rb', line 81 def self.configure self.configuration ||= Configuration.new yield(configuration) self.configuration end |
.enrich(links: {}, attributes: {}) ⇒ Object
The backbone of the Identity API. Enrich accepts links and attributes as per the API Documentation hosted at developer.lexer.io/
Options:
links
- A hash of links to search for and link to the identity. Default: {}. attributes
- A hash of attributes where keys are valid namespaces. Default: {}.
Response:
A hash containing the Lexer Identity ID and any attributes on the identity
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/lexer/identity/api.rb', line 21 def self.enrich(links: {}, attributes: {}) # ensure the module is configured fail Lexer::Identity::ConfigurationError, 'Module has not been configured.' if configuration.nil? configuration.validate # produce the request body body = {} body[:links] = links body[:attributes] = attributes unless configuration.contributor_token.nil? body[:api_token] = configuration.api_token unless configuration.api_token.nil? body[:contributor_token] = configuration.contributor_token unless configuration.contributor_token.nil? body[:consumer_token] = configuration.consumer_token unless configuration.consumer_token.nil? post_request body end |