Class: Endicia::RefundResponse
- Inherits:
-
Object
- Object
- Endicia::RefundResponse
- Defined in:
- lib/endicia_ruby/refund_response.rb
Instance Attribute Summary collapse
-
#form_number ⇒ Object
Returns the value of attribute form_number.
-
#parsed_response ⇒ Object
Returns the value of attribute parsed_response.
-
#raw_response ⇒ Object
Returns the value of attribute raw_response.
-
#success ⇒ Object
Returns the value of attribute success.
-
#tracking_numbers ⇒ Object
Returns the value of attribute tracking_numbers.
Instance Method Summary collapse
-
#initialize(response) ⇒ RefundResponse
constructor
An array with information about all requested tracking numbers 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.
Constructor Details
#initialize(response) ⇒ RefundResponse
An array with information about all requested tracking numbers 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
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# 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 |
Instance Attribute Details
#form_number ⇒ Object
Returns the value of attribute form_number.
7 8 9 |
# File 'lib/endicia_ruby/refund_response.rb', line 7 def form_number @form_number end |
#parsed_response ⇒ Object
Returns the value of attribute parsed_response.
7 8 9 |
# File 'lib/endicia_ruby/refund_response.rb', line 7 def parsed_response @parsed_response end |
#raw_response ⇒ Object
Returns the value of attribute raw_response.
7 8 9 |
# File 'lib/endicia_ruby/refund_response.rb', line 7 def raw_response @raw_response end |
#success ⇒ Object
Returns the value of attribute success.
7 8 9 |
# File 'lib/endicia_ruby/refund_response.rb', line 7 def success @success end |
#tracking_numbers ⇒ Object
Returns the value of attribute tracking_numbers.
7 8 9 |
# File 'lib/endicia_ruby/refund_response.rb', line 7 def tracking_numbers @tracking_numbers end |