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.
-
#forwarded_for ⇒ Object
Returns the value of attribute forwarded_for.
-
#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.
50 51 52 53 54 55 |
# File 'lib/flex_commerce_api/config.rb', line 50 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.
31 32 33 |
# File 'lib/flex_commerce_api/config.rb', line 31 def adapter @adapter end |
#api_version ⇒ Object (readonly)
Returns the value of attribute api_version.
48 49 50 |
# File 'lib/flex_commerce_api/config.rb', line 48 def api_version @api_version end |
#flex_account ⇒ Object
The account to be used on the flex server. For example myaccount
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/flex_commerce_api/config.rb', line 31 attr_accessor( :flex_root_url, :flex_api_key, :flex_account, :logger, :adapter, :http_cache, :open_timeout, :timeout, :paypal_login, :paypal_password, :paypal_signature, :order_test_mode, :paypal_connection_errors_no_of_retries, :forwarded_for ) |
#flex_api_key ⇒ Object
The API key to access the flex server with. This comes from the ‘Access Keys’ section of the admin panel
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/flex_commerce_api/config.rb', line 31 attr_accessor( :flex_root_url, :flex_api_key, :flex_account, :logger, :adapter, :http_cache, :open_timeout, :timeout, :paypal_login, :paypal_password, :paypal_signature, :order_test_mode, :paypal_connection_errors_no_of_retries, :forwarded_for ) |
#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
31 32 33 |
# File 'lib/flex_commerce_api/config.rb', line 31 def flex_root_url @flex_root_url end |
#forwarded_for ⇒ Object
Returns the value of attribute forwarded_for.
31 32 33 |
# File 'lib/flex_commerce_api/config.rb', line 31 def forwarded_for @forwarded_for end |
#http_cache ⇒ Object
Returns the value of attribute http_cache.
31 32 33 |
# File 'lib/flex_commerce_api/config.rb', line 31 def http_cache @http_cache end |
#logger ⇒ Object
Returns the value of attribute logger.
31 32 33 |
# File 'lib/flex_commerce_api/config.rb', line 31 def logger @logger end |
#open_timeout ⇒ Object
Returns the value of attribute open_timeout.
31 32 33 |
# File 'lib/flex_commerce_api/config.rb', line 31 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
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/flex_commerce_api/config.rb', line 31 attr_accessor( :flex_root_url, :flex_api_key, :flex_account, :logger, :adapter, :http_cache, :open_timeout, :timeout, :paypal_login, :paypal_password, :paypal_signature, :order_test_mode, :paypal_connection_errors_no_of_retries, :forwarded_for ) |
#paypal_connection_errors_no_of_retries ⇒ Object
Returns the value of attribute paypal_connection_errors_no_of_retries.
31 32 33 |
# File 'lib/flex_commerce_api/config.rb', line 31 def paypal_connection_errors_no_of_retries @paypal_connection_errors_no_of_retries end |
#paypal_login ⇒ Object
Returns the value of attribute paypal_login.
31 32 33 |
# File 'lib/flex_commerce_api/config.rb', line 31 def paypal_login @paypal_login end |
#paypal_password ⇒ Object
Returns the value of attribute paypal_password.
31 32 33 |
# File 'lib/flex_commerce_api/config.rb', line 31 def paypal_password @paypal_password end |
#paypal_signature ⇒ Object
Returns the value of attribute paypal_signature.
31 32 33 |
# File 'lib/flex_commerce_api/config.rb', line 31 def paypal_signature @paypal_signature end |
#timeout ⇒ Object
Returns the value of attribute timeout.
31 32 33 |
# File 'lib/flex_commerce_api/config.rb', line 31 def timeout @timeout end |
Instance Method Details
#api_base_url ⇒ String
The api base URL
60 61 62 |
# File 'lib/flex_commerce_api/config.rb', line 60 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
67 68 69 |
# File 'lib/flex_commerce_api/config.rb', line 67 def reconfigure_all! FlexCommerceApi::BaseResource.reconfigure_all if FlexCommerceApi.const_defined? "ApiBase" end |