Class: AgentAdmit::Config
- Inherits:
-
Object
- Object
- AgentAdmit::Config
- Defined in:
- lib/agentadmit/config.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#app_id ⇒ Object
Returns the value of attribute app_id.
-
#max_retries ⇒ Object
Returns the value of attribute max_retries.
-
#token_prefix_access ⇒ Object
Returns the value of attribute token_prefix_access.
-
#token_prefix_connection ⇒ Object
Returns the value of attribute token_prefix_connection.
-
#verify_url ⇒ Object
Returns the value of attribute verify_url.
-
#webhook_secret ⇒ Object
Returns the value of attribute webhook_secret.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#validate_api_key! ⇒ Object
Validate the API key prefix (aa_test_/aa_live_) without ever echoing the key itself.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/agentadmit/config.rb', line 14 def initialize @app_id = ENV.fetch("AGENTADMIT_APP_ID", "") @api_key = ENV.fetch("AGENTADMIT_API_KEY", "") @verify_url = ENV.fetch("AGENTADMIT_VERIFY_URL", "https://api.agentadmit.com/api/v1/verify") @api_url = ENV.fetch("AGENTADMIT_API_URL", "https://api.agentadmit.com") @token_prefix_access = "ag_at_" @token_prefix_connection = "ag_ct_" # Webhook signing secret (whsec_…) — shown once when you configure the # alert webhook URL in the dashboard. Used by AgentAdmit::Webhook. @webhook_secret = ENV.fetch("AGENTADMIT_WEBHOOK_SECRET", "") # Max retries on HTTP 429 before raising RateLimitError. Default: 3. @max_retries = ENV.fetch("AGENTADMIT_MAX_RETRIES", "3").to_i end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
10 11 12 |
# File 'lib/agentadmit/config.rb', line 10 def api_key @api_key end |
#api_url ⇒ Object
Returns the value of attribute api_url.
10 11 12 |
# File 'lib/agentadmit/config.rb', line 10 def api_url @api_url end |
#app_id ⇒ Object
Returns the value of attribute app_id.
10 11 12 |
# File 'lib/agentadmit/config.rb', line 10 def app_id @app_id end |
#max_retries ⇒ Object
Returns the value of attribute max_retries.
10 11 12 |
# File 'lib/agentadmit/config.rb', line 10 def max_retries @max_retries end |
#token_prefix_access ⇒ Object
Returns the value of attribute token_prefix_access.
10 11 12 |
# File 'lib/agentadmit/config.rb', line 10 def token_prefix_access @token_prefix_access end |
#token_prefix_connection ⇒ Object
Returns the value of attribute token_prefix_connection.
10 11 12 |
# File 'lib/agentadmit/config.rb', line 10 def token_prefix_connection @token_prefix_connection end |
#verify_url ⇒ Object
Returns the value of attribute verify_url.
10 11 12 |
# File 'lib/agentadmit/config.rb', line 10 def verify_url @verify_url end |
#webhook_secret ⇒ Object
Returns the value of attribute webhook_secret.
10 11 12 |
# File 'lib/agentadmit/config.rb', line 10 def webhook_secret @webhook_secret end |
Instance Method Details
#validate_api_key! ⇒ Object
Validate the API key prefix (aa_test_/aa_live_) without ever echoing the key itself.
34 35 36 37 38 39 |
# File 'lib/agentadmit/config.rb', line 34 def validate_api_key! return if api_key.nil? || api_key.empty? return if api_key.start_with?("aa_test_", "aa_live_") raise ConfigurationError, "api_key must start with 'aa_test_' or 'aa_live_'" end |