Sha256: d2a30e5b1ba388b2752dfb8e3402f2dd7c88fdd88d2bcbdf3ded0a69e03a5dfd
Contents?: true
Size: 1.52 KB
Versions: 6
Compression:
Stored size: 1.52 KB
Contents
# frozen_string_literal: true module PriceHubble # Handles all the identity retrival high-level logic. # # rubocop:disable Style/ClassVars because we split module code module Identity extend ActiveSupport::Concern class_methods do # Reset the current identity. def reset_identity! @@identity = nil end # Get the current identity we use for all requests. We try to # authenticate against the PriceHubble Authentication API with the # configured credentials from the Gem configuration. # (+PriceHubble.configuration+) In case this went well, we cache the # result. Otherwise we raise an +AuthenticationError+. # # @return [PriceHubble::Authentication] the authentication instance # @raise [AuthenticationError] in case of a failed login def identity # Fetch a new identity with the configured identity settings from the # Gem configuration @@identity ||= auth_by_config # Take care of an expired identity @@identity = auth_by_config if @@identity.expired? # Pass back the actual identity instance @@identity end private # Perform the authentication via the configured identity credentials. # # @return [Hausgold::Jwt] the new JWT instance # @raise [AuthenticationError] in case of a failed login def auth_by_config args = identity_params.dup client(:authentication).login!(**args) end end end # rubocop:enable Style/ClassVars end
Version data entries
6 entries across 6 versions & 1 rubygems