Class: Cielo::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/cielo/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConnection

Returns a new instance of Connection.



4
5
6
7
8
9
10
11
# File 'lib/cielo/connection.rb', line 4

def initialize
  @environment = eval(Cielo.environment.to_s.capitalize)
  port = 443
  @http = Net::HTTP.new(@environment::BASE_URL,port)
  @http.use_ssl = true
  @http.open_timeout = 10*1000
  @http.read_timeout = 40*1000
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



3
4
5
# File 'lib/cielo/connection.rb', line 3

def environment
  @environment
end

Instance Method Details

#request!(params = {}) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/cielo/connection.rb', line 13

def request!(params={})
  str_params = ""
  params.each do |key, value| 
    str_params+="&" unless str_params.empty?
    str_params+="#{key}=#{value}"
  end
  @http.request_post(self.environment::WS_PATH, str_params)
end