Module: EasyLabs::Util Private
- Defined in:
- lib/easylabs/util.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Internal helpers that do not belong to a specific resource.
Class Method Summary collapse
-
.validate_api_key(api_key:, api_url:) ⇒ String
private
Validates the API key by calling ‘GET /validate-key` and returning the BasisTheory public api key from the response.
Class Method Details
.validate_api_key(api_key:, api_url:) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Validates the API key by calling ‘GET /validate-key` and returning the BasisTheory public api key from the response. Mirrors `validateApiKey` in @easylabs/common.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/easylabs/util.rb', line 17 def validate_api_key(api_key:, api_url:) http = HTTP.new(api_url: api_url, api_key: api_key) response = http.request(:get, "/validate-key") data = response.is_a?(Hash) ? response[:data] : nil bt_key = data.is_a?(Hash) ? data[:basisTheoryPublicApiKey] : nil unless bt_key raise AuthenticationError.new( "API key validation failed: response did not include basisTheoryPublicApiKey", status: 200, raw: response ) end bt_key end |