Class: ChargeBee::Environment

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Environment

Returns a new instance of Environment.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/chargebee/environment.rb', line 13

def initialize(options)
  options[:time_machine_sleeptime] ||= TIME_MACHINE_TIMEOUT
  options[:export_sleeptime] ||= EXPORT_TIMEOUT
  options[:connect_timeout] ||= CONNECT_TIMEOUT
  options[:read_timeout] ||= READ_TIMEOUT
  [:api_key, :site, :time_machine_sleeptime, :export_sleeptime, :connect_timeout, :read_timeout].each do |attr|
    instance_variable_set "@#{attr}", options[attr]
  end
  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_endpointObject (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_keyObject

Returns the value of attribute api_key.



10
11
12
# File 'lib/chargebee/environment.rb', line 10

def api_key
  @api_key
end

#connect_timeoutObject

Returns the value of attribute connect_timeout.



10
11
12
# File 'lib/chargebee/environment.rb', line 10

def connect_timeout
  @connect_timeout
end

#export_sleeptimeObject

Returns the value of attribute export_sleeptime.



10
11
12
# File 'lib/chargebee/environment.rb', line 10

def export_sleeptime
  @export_sleeptime
end

#read_timeoutObject

Returns the value of attribute read_timeout.



10
11
12
# File 'lib/chargebee/environment.rb', line 10

def read_timeout
  @read_timeout
end

#siteObject

Returns the value of attribute site.



10
11
12
# File 'lib/chargebee/environment.rb', line 10

def site
  @site
end

#time_machine_sleeptimeObject

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) ⇒ Object



28
29
30
# File 'lib/chargebee/environment.rb', line 28

def api_url(url)
  url = @api_endpoint + url
end