Class: USPS::Response::DeliveryConfirmation

Inherits:
Base
  • Object
show all
Defined in:
lib/usps/response/delivery_confirmation.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#raw

Instance Method Summary collapse

Methods inherited from Base

parse

Constructor Details

#initialize(xml) ⇒ DeliveryConfirmation

Returns a new instance of DeliveryConfirmation.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/usps/response/delivery_confirmation.rb', line 7

def initialize(xml)
  # Label is Base64 encoded
  @label = xml.search('DeliveryConfirmationLabel').text.unpack("m*")[0]
  @confirmation = xml.search('DeliveryConfirmationNumber').text
  @postnet = xml.search('Postnet').text

  @address = USPS::Address.new(
    :name     => xml.search('ToName').text,
    :company  => xml.search('ToFirm').text,
    :address  => xml.search('ToAddress2').text,
    :address2 => xml.search('ToAddress1').text,
    :city     => xml.search('ToCity').text,
    :state    => xml.search('ToState').text,
    :zip5     => xml.search('ToZip5').text,
    :zip4     => xml.search('ToZip4').text
  )
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



3
4
5
# File 'lib/usps/response/delivery_confirmation.rb', line 3

def address
  @address
end

#confirmationObject (readonly) Also known as: confirmation_number

Returns the value of attribute confirmation.



3
4
5
# File 'lib/usps/response/delivery_confirmation.rb', line 3

def confirmation
  @confirmation
end

#labelObject (readonly)

Returns the value of attribute label.



3
4
5
# File 'lib/usps/response/delivery_confirmation.rb', line 3

def label
  @label
end

#postnetObject (readonly)

Returns the value of attribute postnet.



3
4
5
# File 'lib/usps/response/delivery_confirmation.rb', line 3

def postnet
  @postnet
end