Class: ChargeBee::Environment
- Inherits:
-
Object
- Object
- ChargeBee::Environment
- Defined in:
- lib/chargebee/environment.rb
Constant Summary collapse
- API_VERSION =
"v2"- TIME_MACHINE_TIMEOUT =
in seconds
3- EXPORT_TIMEOUT =
10- CONNECT_TIMEOUT =
30- READ_TIMEOUT =
80
Instance Attribute Summary collapse
-
#api_endpoint ⇒ Object
readonly
Returns the value of attribute api_endpoint.
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
-
#enable_debug_logs ⇒ Object
Add retry_config and enable_debug_logs.
-
#export_sleeptime ⇒ Object
Returns the value of attribute export_sleeptime.
-
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
-
#retry_config ⇒ Object
Add retry_config and enable_debug_logs.
-
#site ⇒ Object
Returns the value of attribute site.
-
#time_machine_sleeptime ⇒ Object
Returns the value of attribute time_machine_sleeptime.
Instance Method Summary collapse
- #api_url(url, sub_domain = nil) ⇒ Object
-
#initialize(options) ⇒ Environment
constructor
A new instance of Environment.
Constructor Details
#initialize(options) ⇒ Environment
Returns a new instance of Environment.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/chargebee/environment.rb', line 16 def initialize() [:time_machine_sleeptime] ||= TIME_MACHINE_TIMEOUT [:export_sleeptime] ||= EXPORT_TIMEOUT [:connect_timeout] ||= CONNECT_TIMEOUT [:read_timeout] ||= READ_TIMEOUT [:api_key, :site, :time_machine_sleeptime, :export_sleeptime, :connect_timeout, :read_timeout].each do |attr| instance_variable_set "@#{attr}", [attr] end @retry_config = [:retry_config] @enable_debug_logs = [:enable_debug_logs] || false if($CHARGEBEE_DOMAIN == nil) @api_endpoint = "https://#{@site}.chargebee.com/api/#{API_VERSION}" else @api_endpoint = "#{$ENV_PROTOCOL == nil ? "http": "https"}://#{@site}.#{$CHARGEBEE_DOMAIN}/api/#{API_VERSION}" end end |
Instance Attribute Details
#api_endpoint ⇒ Object (readonly)
Returns the value of attribute api_endpoint.
11 12 13 |
# File 'lib/chargebee/environment.rb', line 11 def api_endpoint @api_endpoint end |
#api_key ⇒ Object
Returns the value of attribute api_key.
10 11 12 |
# File 'lib/chargebee/environment.rb', line 10 def api_key @api_key end |
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
10 11 12 |
# File 'lib/chargebee/environment.rb', line 10 def connect_timeout @connect_timeout end |
#enable_debug_logs ⇒ Object
Add retry_config and enable_debug_logs
14 15 16 |
# File 'lib/chargebee/environment.rb', line 14 def enable_debug_logs @enable_debug_logs end |
#export_sleeptime ⇒ Object
Returns the value of attribute export_sleeptime.
10 11 12 |
# File 'lib/chargebee/environment.rb', line 10 def export_sleeptime @export_sleeptime end |
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
10 11 12 |
# File 'lib/chargebee/environment.rb', line 10 def read_timeout @read_timeout end |
#retry_config ⇒ Object
Add retry_config and enable_debug_logs
14 15 16 |
# File 'lib/chargebee/environment.rb', line 14 def retry_config @retry_config end |
#site ⇒ Object
Returns the value of attribute site.
10 11 12 |
# File 'lib/chargebee/environment.rb', line 10 def site @site end |
#time_machine_sleeptime ⇒ Object
Returns the value of attribute time_machine_sleeptime.
10 11 12 |
# File 'lib/chargebee/environment.rb', line 10 def time_machine_sleeptime @time_machine_sleeptime end |
Instance Method Details
#api_url(url, sub_domain = nil) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/chargebee/environment.rb', line 33 def api_url(url, sub_domain = nil) protocol = $ENV_PROTOCOL || "https" domain = $CHARGEBEE_DOMAIN || "chargebee.com" if sub_domain @api_endpoint = "#{protocol}://#{@site}.#{sub_domain}.#{domain}/api/#{API_VERSION}" else @api_endpoint = "#{protocol}://#{@site}.#{domain}/api/#{API_VERSION}" end @api_endpoint + url end |