class Endicia::RefundResponse
Attributes
form_number[RW]
parsed_response[RW]
raw_response[RW]
success[RW]
tracking_numbers[RW]
Public Class Methods
new(response)
click to toggle source
Each entry is an OpenStruct with:
pic_number: '123456789', # the tracking number you requested approved: true, # or false message: "the message" # message describing success or failure
# File lib/endicia_ruby/refund_response.rb, line 18 def initialize(response) @success = true @tracking_numbers = [] @raw_response = response.body @parsed_response = Nokogiri::XML(response.body) refund_response = @parsed_response.xpath('/RefundResponse') @form_number = refund_response.at('FormNumber').content refund_list = refund_response.at('RefundList') refund_list.xpath('//PICNumber').each do |refund_node| approved = refund_node.at('IsApproved').content.try(:strip).try(:upcase) == "YES" @tracking_numbers << OpenStruct.new(pic_number: refund_node.children.first.text.try(:strip), approved: approved, message: refund_node.at('ErrorMsg').content.try(:strip)) @success = @success && approved end end