Class: AuctionInc::Shipping::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/auction_inc/shipping/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml_string) ⇒ Response

Returns a new instance of Response.



6
7
8
9
# File 'lib/auction_inc/shipping/response.rb', line 6

def initialize(xml_string)
  self.raw =  xml_string
  self.parsed = Envelope.from_xml(self.raw)
end

Instance Attribute Details

#parsedObject

Returns the value of attribute parsed.



4
5
6
# File 'lib/auction_inc/shipping/response.rb', line 4

def parsed
  @parsed
end

#rawObject

Returns the value of attribute raw.



4
5
6
# File 'lib/auction_inc/shipping/response.rb', line 4

def raw
  @raw
end

Instance Method Details

#bodyObject



11
12
13
# File 'lib/auction_inc/shipping/response.rb', line 11

def body
  self.parsed.body
end

#errorObject



20
21
22
23
24
25
26
27
28
# File 'lib/auction_inc/shipping/response.rb', line 20

def error
  if self.body.error.present?
    self.body.error 
  elsif self.body.item_ship_rate.present? && self.body.item_ship_rate.has_errors?
    self.body.item_ship_rate.error
  else
    nil
  end
end

#has_error?Boolean Also known as: has_errors?

Returns:

  • (Boolean)


15
16
17
# File 'lib/auction_inc/shipping/response.rb', line 15

def has_error?
  self.body.error.present? || (self.body.item_ship_rate.present? && self.body.item_ship_rate.has_errors?)
end

#ship_ratesObject



30
31
32
# File 'lib/auction_inc/shipping/response.rb', line 30

def ship_rates
  self.parsed.body.item_ship_rate.ship_rates if self.body.item_ship_rate.present?
end