class Starapi::SoapServiceTarget::PriceQuote

Attributes

entno[RW]
last_response[R]
request_date[RW]
request_xml[R]
rev_type[RW]
supno[RW]

Public Class Methods

new(entno, supno, rev_type, request_date) click to toggle source
# File lib/starapi/soap_service_target/price_quote.rb, line 39
def initialize(entno, supno, rev_type, request_date)
  @entno, @supno, @rev_type, @request_date = entno, supno, rev_type, request_date
end

Public Instance Methods

construct_xml() click to toggle source
# File lib/starapi/soap_service_target/price_quote.rb, line 43
def construct_xml
  Nokogiri::XML::Builder.new do |xml|
    xml.ReadiSystem do
      xml.proc_type @@PROC_TYPE
      xml.entno @entno
      xml.supno @supno
      xml.rev_type @rev_type
      xml.request_date @request_date
    end
  end
end
parse_response() click to toggle source
# File lib/starapi/soap_service_target/price_quote.rb, line 60
def parse_response
  if @last_response.blank?
    raise StandardError.new "Response is not loaded. It looks like the request was not made."
  end

  xml = Nokogiri::XML(@last_response)

  parsed_obj = OpenStruct.new

  parsed_obj.entno            = xml.xpath("//entno").text
  parsed_obj.supno            = xml.xpath("//supno").text
  parsed_obj.offer_desc       = xml.xpath("//offer_desc").text
  parsed_obj.rev_type         = xml.xpath("//rev_type").text
  parsed_obj.price_desc       = xml.xpath("//price_desc").text
  parsed_obj.enroll_eff_date  = xml.xpath("//enroll_eff_date").text
  parsed_obj.enroll_exp_date  = xml.xpath("//enroll_exp_date").text
  parsed_obj.offer_price      = xml.xpath("//offer_price").text
  parsed_obj.price_uom        = xml.xpath("//price_uom").text
  parsed_obj.price_to_compare = xml.xpath("//price_to_compare").text
  parsed_obj.ptc_message      = xml.xpath("//ptc_message").text
  parsed_obj
end
soap_price_quote!() click to toggle source
# File lib/starapi/soap_service_target/price_quote.rb, line 55
def soap_price_quote!
  @request_xml = construct_xml.to_xml
  @last_response = get_target_response soap_service_sp.soap_execute_sp!(@request_xml)
end

Private Instance Methods

get_target_response(response) click to toggle source
# File lib/starapi/soap_service_target/price_quote.rb, line 84
def get_target_response(response)
  xml   = Nokogiri::XML(response.body)
  xpath = '/soap:Envelope/soap:Body'
  xml.xpath(xpath).text
end