Class: AbacatePay::Configuration
- Inherits:
-
Object
- Object
- AbacatePay::Configuration
- Defined in:
- lib/abacate_pay/configuration.rb
Overview
Configuration class for the AbacatePay SDK
This class handles all configuration options for the SDK, including API credentials and request behaviour.
Constant Summary collapse
- API_BASE_URL =
The only base URL this SDK speaks. v1 still exists, but under a different dialect, singular paths (
/v1/billing/,/v1/customer/) and different resource names (pixQrCode), which this SDK has never implemented. Deriving a base URL from the token prefix only produced 404s against v1 while sending v2-shaped paths. "https://api.abacatepay.com/v2"
Instance Attribute Summary collapse
-
#api_token ⇒ String
API token for authentication.
-
#environment ⇒ nil
deprecated
Deprecated.
The environment is determined by the API key itself, keys created in Dev mode produce simulated transactions, production keys produce real ones. This setting has never had any effect and is kept only so existing initializers keep loading.
-
#logger ⇒ Logger?
Optional logger.
-
#max_retries ⇒ Integer
Retries apply to idempotent requests only (GET/HEAD/OPTIONS) on 429 and 5xx, with exponential backoff and jitter.
-
#timeout ⇒ Integer
Request timeout in seconds.
Instance Method Summary collapse
-
#api_url ⇒ String
Gets the base API URL.
-
#initialize ⇒ Configuration
constructor
Initialize a new configuration with default values.
-
#validate! ⇒ void
Validates the configuration.
Constructor Details
#initialize ⇒ Configuration
Initialize a new configuration with default values
39 40 41 42 43 44 |
# File 'lib/abacate_pay/configuration.rb', line 39 def initialize @timeout = 30 @max_retries = 2 @logger = nil @api_token = nil end |
Instance Attribute Details
#api_token ⇒ String
Returns API token for authentication.
19 20 21 |
# File 'lib/abacate_pay/configuration.rb', line 19 def api_token @api_token end |
#environment ⇒ nil
The environment is determined by the API key itself, keys created in Dev mode produce simulated transactions, production keys produce real ones. This setting has never had any effect and is kept only so existing initializers keep loading.
51 52 53 |
# File 'lib/abacate_pay/configuration.rb', line 51 def environment @environment end |
#logger ⇒ Logger?
Optional logger. Request and response headers are logged with the bearer token redacted; bodies are never logged, since they carry customer PII.
34 35 36 |
# File 'lib/abacate_pay/configuration.rb', line 34 def logger @logger end |
#max_retries ⇒ Integer
Retries apply to idempotent requests only (GET/HEAD/OPTIONS) on 429 and 5xx, with exponential backoff and jitter. Set to 0 to disable.
28 29 30 |
# File 'lib/abacate_pay/configuration.rb', line 28 def max_retries @max_retries end |
#timeout ⇒ Integer
Returns Request timeout in seconds.
22 23 24 |
# File 'lib/abacate_pay/configuration.rb', line 22 def timeout @timeout end |
Instance Method Details
#api_url ⇒ String
Gets the base API URL
79 80 81 |
# File 'lib/abacate_pay/configuration.rb', line 79 def api_url API_BASE_URL end |
#validate! ⇒ void
This method returns an undefined value.
Validates the configuration
69 70 71 72 |
# File 'lib/abacate_pay/configuration.rb', line 69 def validate! raise ConfigurationError, "API token is required" if api_token.nil? raise ConfigurationError, "API token must not be empty" if api_token.to_s.strip.empty? end |