Class: SimpleShipping::Ups::Response

Inherits:
Abstract::Response show all
Defined in:
lib/simple_shipping/ups/response.rb

Overview

Response from UPS.

Instance Attribute Summary

Attributes inherited from Abstract::Response

#response

Instance Method Summary collapse

Methods inherited from Abstract::Response

#initialize

Constructor Details

This class inherits a constructor from SimpleShipping::Abstract::Response

Instance Method Details

#digestString

Digest what can be used to get a label.

Returns:

  • (String)


7
8
9
# File 'lib/simple_shipping/ups/response.rb', line 7

def digest
  value_of(:shipment_results, :shipment_digest)
end

#label_htmlString

Label image.

Returns:

  • (String)

    binary



36
37
38
39
# File 'lib/simple_shipping/ups/response.rb', line 36

def label_html
  value = value_of(:shipment_results, :package_results, :shipping_label, :html_image)
  Base64.decode64(value) if value
end

#label_image_base64Object

Get the label as base64 encoded data

response.label_image_base64 # => "odGqk/KmgLaawV..."

This can be used directly in an HTML image tag with

src="data:image/gif;base64,..."


29
30
31
# File 'lib/simple_shipping/ups/response.rb', line 29

def label_image_base64
  value_of(:shipment_results, :package_results, :shipping_label, :graphic_image)
end

#receipt_htmlString

Receipt.

Returns:

  • (String)

    binary



44
45
46
47
# File 'lib/simple_shipping/ups/response.rb', line 44

def receipt_html
  value = value_of(:shipment_results, :control_log_receipt, :graphic_image)
  Base64.decode64(value) if value
end

#shipment_identification_numberStrig

Unique shipment ID returned by UPS.

Returns:

  • (Strig)


14
15
16
# File 'lib/simple_shipping/ups/response.rb', line 14

def shipment_identification_number
  value_of(:shipment_results, :shipment_identification_number)
end

#tracking_numberString

Get package tracking number to look for delivery process on UPS site.

Returns:

  • (String)

    tracking number



21
22
23
# File 'lib/simple_shipping/ups/response.rb', line 21

def tracking_number
  value_of(:shipment_results, :package_results, :tracking_number)
end

#value_of(*path) ⇒ Object

Fetch the value of an XML attribute at the path specified as an array of node names but appends the implicit namespace on to the front of the path.



52
53
54
# File 'lib/simple_shipping/ups/response.rb', line 52

def value_of(*path)
  super(*path.unshift(name_token))
end