Class: Fengqiao::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/fengqiao/request.rb

Instance Method Summary collapse

Constructor Details

#initialize(req_xml) ⇒ Request

Returns a new instance of Request.



8
9
10
# File 'lib/fengqiao/request.rb', line 8

def initialize(req_xml)
  @req_xml = req_xml
end

Instance Method Details

#doObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fengqiao/request.rb', line 12

def do
  str = @req_xml + Fengqiao.check_word

  verifyCode = Digest::MD5.base64digest(str)

  data = { xml: @req_xml, verifyCode: verifyCode }

  res = ::Faraday.new(url: SEND_GATEWAY).post do |req|
    req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
    req.body = data
  end

  REXML::Document.new res.body
end