Class: Cdek::Configuration
- Inherits:
-
Object
- Object
- Cdek::Configuration
- Defined in:
- lib/cdek/configuration.rb
Overview
Конфигурация гема.
Cdek.configure do |config|
config.account = ENV["CDEK_ACCOUNT"]
config.secure_password = ENV["CDEK_SECURE_PASSWORD"]
config.production_mode!
end
Constant Summary collapse
- PRODUCTION_URL =
"https://api.cdek.ru/v2"- TEST_URL =
"https://api.edu.cdek.ru/v2"- SANDBOX_ACCOUNT =
Тестовые учётные данные CDEK для песочницы публикуются в их документации. Указываются здесь только как ссылка для удобства, ничего не предзаполняется.
"EMscd6r9JnFiQ3bLoyjJY6eM78JrJceI"- SANDBOX_SECURE_PASSWORD =
"PjLZkKBHEiLK3YsHzqYDqQYj1pSwOaNB"
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
-
#secure_password ⇒ Object
Returns the value of attribute secure_password.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
Instance Method Summary collapse
- #credentials_present? ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #production_mode! ⇒ Object
- #test_mode! ⇒ Object
- #use_sandbox_credentials! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
28 29 30 31 32 33 34 35 36 |
# File 'lib/cdek/configuration.rb', line 28 def initialize @account = nil @secure_password = nil @base_url = TEST_URL @timeout = 15 @open_timeout = 5 @logger = nil @user_agent = "cdek-ruby/#{Cdek::VERSION}" end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
20 21 22 |
# File 'lib/cdek/configuration.rb', line 20 def account @account end |
#base_url ⇒ Object
Returns the value of attribute base_url.
20 21 22 |
# File 'lib/cdek/configuration.rb', line 20 def base_url @base_url end |
#logger ⇒ Object
Returns the value of attribute logger.
20 21 22 |
# File 'lib/cdek/configuration.rb', line 20 def logger @logger end |
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
20 21 22 |
# File 'lib/cdek/configuration.rb', line 20 def open_timeout @open_timeout end |
#secure_password ⇒ Object
Returns the value of attribute secure_password.
20 21 22 |
# File 'lib/cdek/configuration.rb', line 20 def secure_password @secure_password end |
#timeout ⇒ Object
Returns the value of attribute timeout.
20 21 22 |
# File 'lib/cdek/configuration.rb', line 20 def timeout @timeout end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
20 21 22 |
# File 'lib/cdek/configuration.rb', line 20 def user_agent @user_agent end |
Instance Method Details
#credentials_present? ⇒ Boolean
52 53 54 |
# File 'lib/cdek/configuration.rb', line 52 def credentials_present? account.to_s.strip.length.positive? && secure_password.to_s.strip.length.positive? end |
#production_mode! ⇒ Object
42 43 44 |
# File 'lib/cdek/configuration.rb', line 42 def production_mode! @base_url = PRODUCTION_URL end |
#test_mode! ⇒ Object
38 39 40 |
# File 'lib/cdek/configuration.rb', line 38 def test_mode! @base_url = TEST_URL end |
#use_sandbox_credentials! ⇒ Object
46 47 48 49 50 |
# File 'lib/cdek/configuration.rb', line 46 def use_sandbox_credentials! @account = SANDBOX_ACCOUNT @secure_password = SANDBOX_SECURE_PASSWORD test_mode! end |