class PagseguroCatcher::Transaction::Shipping
This class is responsable for parsing the shipping values of the xml.
The part that it parsers is the following:
<shipping> <address> <street>Av. Brig. Faria Lima</street> <number>1384</number> <complement>5o andar</complement> <district>Jardim Paulistano</district> <postalCode>01452002</postalCode> <city>Sao Paulo</city> <state>SP</state> <country>BRA</country> </address> <type>1</type> <cost>21.50</cost> </shipping>
Public Class Methods
new(body)
click to toggle source
# File lib/pagseguro_catcher/transaction/shipping.rb, line 24 def initialize(body) self.body = body[:shipping] end
Public Instance Methods
cost()
click to toggle source
The the shipping cost as a float
shipping.cost # => 21.50
# File lib/pagseguro_catcher/transaction/shipping.rb, line 42 def cost self[:cost].to_f end
human_type()
click to toggle source
The human readable value for the shipping type
shipping.human_type # => "Encomenda normal (PAC)"
# File lib/pagseguro_catcher/transaction/shipping.rb, line 36 def human_type SHIPPING_TYPES[self[:type].to_i] end
method_missing(name, *args)
click to toggle source
method_missing
will try to find anything inside the address node
shipping.street # => "Av. Brig. Faria Lima"
Calls superclass method
PagseguroCatcher::Transaction::Body#method_missing
# File lib/pagseguro_catcher/transaction/shipping.rb, line 48 def method_missing(name, *args) return self[:address][name] if self.body[:address].has_key?(name.to_sym) super end
zip()
click to toggle source
Returns the zip number as a string
shipping.zip # => "012345"
# File lib/pagseguro_catcher/transaction/shipping.rb, line 30 def zip self[:address][:postalCode] end