Class: FlexCommerceApi::Config
- Inherits:
-
Object
- Object
- FlexCommerceApi::Config
- Includes:
- Singleton
- Defined in:
- lib/flex_commerce_api/config.rb
Overview
Global configuration object
This is not accessed directly but using code similar to this example :-
FlexCommerceApi.config do |config|
config.flex_root_url=ENV["FLEX_ROOT_URL"]
config.flex_account=ENV["FLEX_ACCOUNT"]
config.flex_api_key=ENV["FLEX_API_KEY"]
config.logger = Rails.logger
config.order_test_mode = ENV.key?("ORDER_TEST_MODE")
end
The above code would typically be found in a rails initializer as an example.
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#api_version ⇒ Object
readonly
Returns the value of attribute api_version.
-
#flex_account ⇒ Object
The account to be used on the flex server.
-
#flex_api_key ⇒ Object
The API key to access the flex server with.
-
#flex_root_url ⇒ Object
The root url for the flex server.
-
#http_cache ⇒ Object
Returns the value of attribute http_cache.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
-
#order_test_mode ⇒ Object
The order test mode.This config determines if orders are processed as test or real orders.
-
#paypal_connection_errors_no_of_retries ⇒ Object
Returns the value of attribute paypal_connection_errors_no_of_retries.
-
#paypal_login ⇒ Object
Returns the value of attribute paypal_login.
-
#paypal_password ⇒ Object
Returns the value of attribute paypal_password.
-
#paypal_signature ⇒ Object
Returns the value of attribute paypal_signature.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#api_base_url ⇒ String
The api base URL.
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#reconfigure_all! ⇒ Object
Informs all models that the configuration may have changed but only if ApiBase is defined - else nothing has loaded yet so they wont need reconfiguring.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
33 34 35 36 37 38 |
# File 'lib/flex_commerce_api/config.rb', line 33 def initialize self.order_test_mode = false self.http_cache = {} self.open_timeout = ENV.fetch('SHIFT_OPEN_TIMEOUT', 2).to_i self.timeout = ENV.fetch('SHIFT_TIMEOUT', 15).to_i end |
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
30 31 32 |
# File 'lib/flex_commerce_api/config.rb', line 30 def adapter @adapter end |
#api_version ⇒ Object (readonly)
Returns the value of attribute api_version.
31 32 33 |
# File 'lib/flex_commerce_api/config.rb', line 31 def api_version @api_version end |
#flex_account ⇒ Object
The account to be used on the flex server. For example myaccount
30 |
# File 'lib/flex_commerce_api/config.rb', line 30 attr_accessor :flex_root_url, :flex_api_key, :flex_account, :logger, :adapter, :order_test_mode, :http_cache, :open_timeout, :timeout, :paypal_login, :paypal_password, :paypal_signature, :order_test_mode, :paypal_connection_errors_no_of_retries |
#flex_api_key ⇒ Object
The API key to access the flex server with. This comes from the ‘Access Keys’ section of the admin panel
30 |
# File 'lib/flex_commerce_api/config.rb', line 30 attr_accessor :flex_root_url, :flex_api_key, :flex_account, :logger, :adapter, :order_test_mode, :http_cache, :open_timeout, :timeout, :paypal_login, :paypal_password, :paypal_signature, :order_test_mode, :paypal_connection_errors_no_of_retries |
#flex_root_url ⇒ Object
The root url for the flex server. Must NOT include the account name at the end For example api.flexcommerce.com
30 31 32 |
# File 'lib/flex_commerce_api/config.rb', line 30 def flex_root_url @flex_root_url end |
#http_cache ⇒ Object
Returns the value of attribute http_cache.
30 31 32 |
# File 'lib/flex_commerce_api/config.rb', line 30 def http_cache @http_cache end |
#logger ⇒ Object
Returns the value of attribute logger.
30 31 32 |
# File 'lib/flex_commerce_api/config.rb', line 30 def logger @logger end |
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
30 31 32 |
# File 'lib/flex_commerce_api/config.rb', line 30 def open_timeout @open_timeout end |
#order_test_mode ⇒ Object
The order test mode.This config determines if orders are processed as test or real orders
30 |
# File 'lib/flex_commerce_api/config.rb', line 30 attr_accessor :flex_root_url, :flex_api_key, :flex_account, :logger, :adapter, :order_test_mode, :http_cache, :open_timeout, :timeout, :paypal_login, :paypal_password, :paypal_signature, :order_test_mode, :paypal_connection_errors_no_of_retries |
#paypal_connection_errors_no_of_retries ⇒ Object
Returns the value of attribute paypal_connection_errors_no_of_retries.
30 31 32 |
# File 'lib/flex_commerce_api/config.rb', line 30 def paypal_connection_errors_no_of_retries @paypal_connection_errors_no_of_retries end |
#paypal_login ⇒ Object
Returns the value of attribute paypal_login.
30 31 32 |
# File 'lib/flex_commerce_api/config.rb', line 30 def paypal_login @paypal_login end |
#paypal_password ⇒ Object
Returns the value of attribute paypal_password.
30 31 32 |
# File 'lib/flex_commerce_api/config.rb', line 30 def paypal_password @paypal_password end |
#paypal_signature ⇒ Object
Returns the value of attribute paypal_signature.
30 31 32 |
# File 'lib/flex_commerce_api/config.rb', line 30 def paypal_signature @paypal_signature end |
#timeout ⇒ Object
Returns the value of attribute timeout.
30 31 32 |
# File 'lib/flex_commerce_api/config.rb', line 30 def timeout @timeout end |
Instance Method Details
#api_base_url ⇒ String
The api base URL
43 44 45 |
# File 'lib/flex_commerce_api/config.rb', line 43 def api_base_url "#{flex_root_url}/#{flex_account}" end |
#reconfigure_all! ⇒ Object
Informs all models that the configuration may have changed but only if ApiBase is defined - else nothing has loaded yet so they wont need reconfiguring
50 51 52 |
# File 'lib/flex_commerce_api/config.rb', line 50 def reconfigure_all! FlexCommerceApi::BaseResource.reconfigure_all if FlexCommerceApi.const_defined? "ApiBase" end |