Class: Yookassa::Configuration
- Inherits:
-
Object
- Object
- Yookassa::Configuration
- Defined in:
- lib/yookassa/configuration.rb
Overview
Holds API credentials and connection settings for the YooKassa API.
Instance Attribute Summary collapse
-
#api_key ⇒ String?
Secret API key for Basic auth.
-
#auth_token ⇒ String?
OAuth token (used instead of shop_id/api_key when set).
-
#logger ⇒ Logger?
Optional logger for request/response debugging.
-
#max_retries ⇒ Integer
Maximum number of retries on failure (default: 3).
-
#retry_delay ⇒ Float
Base delay between retries in seconds (default: 1.8).
-
#shop_id ⇒ String?
YooKassa shop (merchant) identifier.
-
#timeout ⇒ Integer
HTTP request timeout in seconds (default: 30).
Instance Method Summary collapse
-
#credentials ⇒ Hash
Returns the active credential set for HTTP authentication.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#validate ⇒ Boolean
Checks whether credentials are present (non-raising).
-
#validate! ⇒ void
Validates that credentials are present, raising on failure.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
38 39 40 41 42 43 |
# File 'lib/yookassa/configuration.rb', line 38 def initialize @timeout = 30 @max_retries = 3 @retry_delay = 1.8 @logger = nil end |
Instance Attribute Details
#api_key ⇒ String?
Returns secret API key for Basic auth.
21 22 23 |
# File 'lib/yookassa/configuration.rb', line 21 def api_key @api_key end |
#auth_token ⇒ String?
Returns OAuth token (used instead of shop_id/api_key when set).
24 25 26 |
# File 'lib/yookassa/configuration.rb', line 24 def auth_token @auth_token end |
#logger ⇒ Logger?
Returns optional logger for request/response debugging.
36 37 38 |
# File 'lib/yookassa/configuration.rb', line 36 def logger @logger end |
#max_retries ⇒ Integer
Returns maximum number of retries on failure (default: 3).
30 31 32 |
# File 'lib/yookassa/configuration.rb', line 30 def max_retries @max_retries end |
#retry_delay ⇒ Float
Returns base delay between retries in seconds (default: 1.8).
33 34 35 |
# File 'lib/yookassa/configuration.rb', line 33 def retry_delay @retry_delay end |
#shop_id ⇒ String?
Returns YooKassa shop (merchant) identifier.
18 19 20 |
# File 'lib/yookassa/configuration.rb', line 18 def shop_id @shop_id end |
#timeout ⇒ Integer
Returns HTTP request timeout in seconds (default: 30).
27 28 29 |
# File 'lib/yookassa/configuration.rb', line 27 def timeout @timeout end |
Instance Method Details
#credentials ⇒ Hash
Returns the active credential set for HTTP authentication.
69 70 71 72 73 74 75 |
# File 'lib/yookassa/configuration.rb', line 69 def credentials if auth_token && !auth_token.to_s.empty? { auth_token: auth_token } else { shop_id: shop_id, api_key: api_key } end end |
#validate ⇒ Boolean
Checks whether credentials are present (non-raising).
48 49 50 51 52 53 54 |
# File 'lib/yookassa/configuration.rb', line 48 def validate return true unless auth_token.to_s.empty? return false if shop_id.to_s.empty? return false if api_key.to_s.empty? true end |
#validate! ⇒ void
This method returns an undefined value.
Validates that credentials are present, raising on failure.
60 61 62 63 64 |
# File 'lib/yookassa/configuration.rb', line 60 def validate! return unless auth_token.to_s.empty? raise Yookassa::Error, "shop_id is required (or provide auth_token)" if shop_id.to_s.empty? raise Yookassa::Error, "api_key is required (or provide auth_token)" if api_key.to_s.empty? end |