1.首先当然是添加 gem,然后 bundle install; 2.在你的 class 里包括 HTTParty; 3.我所做的是需要发送 post 请求来判断 fax 的状态是否成功,sending?sent?还是 failed?,用 Nokogiri::XML 来解析得到自己想要的结点值来继续下一步逻辑;
class PurchaseOrderFaxStatusUpdater
include HTTParty
def get_fax_status(job_id)
status = {}
response = self.class.post(SERVER URL, :body => YOUR BODY CONTENT, :headers => {'Content-type' => 'text/xml'})
if response.response.is_a? Net::HTTPOK # httparty response is NET::HTTP, response ok here then go on
xml_doc= Nokogiri::XML(response.body)
node = xml_doc.xpath("//namespace:#{NODE NAME}", 'namespace' => YOUR NAMESPACE).first
#YOUR LOGIC HERE
end
end
end