Class: PSWinCom::HttpSender

Inherits:
Object
  • Object
show all
Defined in:
lib/pswincom/httpsender.rb

Constant Summary collapse

API_HOST =
'http://gw2-fro.pswin.com:81/'

Instance Method Summary collapse

Constructor Details

#initializeHttpSender

Returns a new instance of HttpSender.



8
9
10
11
# File 'lib/pswincom/httpsender.rb', line 8

def initialize
  @host = API.api_host || API_HOST
  PSWinCom.debug "Host", @host
end

Instance Method Details

#send(request) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/pswincom/httpsender.rb', line 13

def send request
  url = URI.parse @host
  post = Net::HTTP::Post.new(url.path)
  post.body = request.xml
  post.content_type = 'text/xml'
  Net::HTTP.start(url.host, url.port) {|http| http.request(post)}
end