Class: AgentAdmit::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/agentadmit/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Config

Returns a new instance of Config.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/agentadmit/config.rb', line 17

def initialize
  @app_id = ENV.fetch("AGENTADMIT_APP_ID", "")
  @api_key = ENV.fetch("AGENTADMIT_API_KEY", "")
  self.verify_url = ENV.fetch("AGENTADMIT_VERIFY_URL", "https://api.agentadmit.com/api/v1/verify")
  self.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.



12
13
14
# File 'lib/agentadmit/config.rb', line 12

def api_key
  @api_key
end

#api_url ⇒ Object

Returns the value of attribute api_url.



15
16
17
# File 'lib/agentadmit/config.rb', line 15

def api_url
  @api_url
end

#app_id ⇒ Object

Returns the value of attribute app_id.



12
13
14
# File 'lib/agentadmit/config.rb', line 12

def app_id
  @app_id
end

#max_retries ⇒ Object

Returns the value of attribute max_retries.



12
13
14
# File 'lib/agentadmit/config.rb', line 12

def max_retries
  @max_retries
end

#token_prefix_access ⇒ Object

Returns the value of attribute token_prefix_access.



12
13
14
# File 'lib/agentadmit/config.rb', line 12

def token_prefix_access
  @token_prefix_access
end

#token_prefix_connection ⇒ Object

Returns the value of attribute token_prefix_connection.



12
13
14
# File 'lib/agentadmit/config.rb', line 12

def token_prefix_connection
  @token_prefix_connection
end

#verify_url ⇒ Object

Returns the value of attribute verify_url.



15
16
17
# File 'lib/agentadmit/config.rb', line 15

def verify_url
  @verify_url
end

#webhook_secret ⇒ Object

Returns the value of attribute webhook_secret.



12
13
14
# File 'lib/agentadmit/config.rb', line 12

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.

Raises:



47
48
49
50
51
52
# File 'lib/agentadmit/config.rb', line 47

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