Class: AbacatePay::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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_tokenString

Returns API token for authentication.

Returns:

  • (String)

    API token for authentication



19
20
21
# File 'lib/abacate_pay/configuration.rb', line 19

def api_token
  @api_token
end

#environmentnil

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.

Returns:

  • (nil)


51
52
53
# File 'lib/abacate_pay/configuration.rb', line 51

def environment
  @environment
end

#loggerLogger?

Optional logger. Request and response headers are logged with the bearer token redacted; bodies are never logged, since they carry customer PII.

Returns:

  • (Logger, nil)


34
35
36
# File 'lib/abacate_pay/configuration.rb', line 34

def logger
  @logger
end

#max_retriesInteger

Retries apply to idempotent requests only (GET/HEAD/OPTIONS) on 429 and 5xx, with exponential backoff and jitter. Set to 0 to disable.

Returns:

  • (Integer)

    Maximum retry attempts



28
29
30
# File 'lib/abacate_pay/configuration.rb', line 28

def max_retries
  @max_retries
end

#timeoutInteger

Returns Request timeout in seconds.

Returns:

  • (Integer)

    Request timeout in seconds



22
23
24
# File 'lib/abacate_pay/configuration.rb', line 22

def timeout
  @timeout
end

Instance Method Details

#api_urlString

Gets the base API URL

Returns:

  • (String)

    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

Raises:



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