Class: SplitIoClient::Engine::AuthApiClient
- Inherits:
-
Object
- Object
- SplitIoClient::Engine::AuthApiClient
- Defined in:
- lib/splitclient-rb/engine/auth_api_client.rb
Instance Method Summary collapse
- #authenticate(api_key) ⇒ Object
-
#initialize(config) ⇒ AuthApiClient
constructor
A new instance of AuthApiClient.
Constructor Details
#initialize(config) ⇒ AuthApiClient
Returns a new instance of AuthApiClient.
9 10 11 12 |
# File 'lib/splitclient-rb/engine/auth_api_client.rb', line 9 def initialize(config) @config = config @api_client = SplitIoClient::Api::Client.new(@config) end |
Instance Method Details
#authenticate(api_key) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/splitclient-rb/engine/auth_api_client.rb', line 14 def authenticate(api_key) response = @api_client.get_api(@config.auth_service_url, api_key) return process_success(response) if response.success? if response.status >= 400 && response.status < 500 @config.logger.debug("Error connecting to: #{@config.auth_service_url}. Response status: #{response.status}") return { push_enabled: false, retry: false } end @config.logger.debug("Error connecting to: #{@config.auth_service_url}. Response status: #{response.status}") { push_enabled: false, retry: true } rescue StandardError => e @config.logger.debug("AuthApiClient error: #{e.inspect}.") { push_enabled: false, retry: false } end |