Module: EasyLabs::ApiUrl

Defined in:
lib/easylabs/api_url.rb

Overview

Resolves the Easy Labs API base URL based on the api key prefix and an optional ‘dev` flag. Mirrors `getAPIUrl` in @easylabs/common.

Constant Summary collapse

EASY_API_URL_DEV =
"https://easy-api-dvjr.onrender.com/v1/api"
EASY_API_URL_PROD =
"https://api.itseasy.co/v1/api"
EASY_API_URL_SANDBOX =
"https://sandbox-api.itseasy.co/v1/api"
BASIS_THEORY_API_URL =
"https://api.basistheory.com"
SANDBOX_KEY_PREFIX =
"sk_test_"

Class Method Summary collapse

Class Method Details

.resolve(api_key:, dev: false) ⇒ String

Returns the resolved base URL.

Parameters:

  • api_key (String)

    the Easy Labs API key.

  • dev (Boolean) (defaults to: false)

    when true, force the dev API URL regardless of key.

Returns:

  • (String)

    the resolved base URL.



18
19
20
21
22
23
# File 'lib/easylabs/api_url.rb', line 18

def resolve(api_key:, dev: false)
  return EASY_API_URL_DEV if dev == true
  return EASY_API_URL_SANDBOX if api_key.is_a?(String) && api_key.start_with?(SANDBOX_KEY_PREFIX)

  EASY_API_URL_PROD
end