Class: SimpleShipping::Ups::Response
- Inherits:
-
Abstract::Response
- Object
- Abstract::Response
- SimpleShipping::Ups::Response
- Defined in:
- lib/simple_shipping/ups/response.rb
Overview
Response from UPS.
Direct Known Subclasses
ShipAcceptResponse, ShipConfirmResponse, ShipmentResponse, VoidResponse
Instance Attribute Summary
Attributes inherited from Abstract::Response
Instance Method Summary collapse
-
#digest ⇒ String
Digest what can be used to get a label.
-
#label_html ⇒ String
Label image.
-
#label_image_base64 ⇒ Object
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,…”.
-
#receipt_html ⇒ String
Receipt.
-
#shipment_identification_number ⇒ Strig
Unique shipment ID returned by UPS.
-
#tracking_number ⇒ String
Get package tracking number to look for delivery process on UPS site.
-
#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.
Methods inherited from Abstract::Response
Constructor Details
This class inherits a constructor from SimpleShipping::Abstract::Response
Instance Method Details
#digest ⇒ String
Digest what can be used to get a label.
7 8 9 |
# File 'lib/simple_shipping/ups/response.rb', line 7 def digest value_of(:shipment_results, :shipment_digest) end |
#label_html ⇒ String
Label image.
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_base64 ⇒ Object
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_html ⇒ String
Receipt.
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_number ⇒ Strig
Unique shipment ID returned by UPS.
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_number ⇒ String
Get package tracking number to look for delivery process on UPS site.
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 |