Skip to content
Browse files

endicia international labels are all thermal

  • Loading branch information...
1 parent 9f25642 commit 2c23a0d5c6c26d344cc3a3af91d3efdaa5d37743 @troystribling troystribling committed Feb 28, 2012
Showing with 40 additions and 7 deletions.
  1. +15 −5 lib/active_shipping/shipping/carriers/endicia.rb
  2. +13 −1 test/remote/endicia_test.rb
  3. +12 −1 test/test_helper.rb
View
20 lib/active_shipping/shipping/carriers/endicia.rb
@@ -68,7 +68,7 @@ def buy_shipping_labels(shipment)
response = commit(:get_postage_label, request)
shipment.log(response)
File.open('/tmp/endicia-response.xml', 'wb'){|f| f << response}
- parse_label_response(package, response, shipment.international?)
+ parse_label_response(package, response, shipment)
package.label
end
shipment
@@ -82,7 +82,7 @@ def validate_shipment(shipment)
response = commit(:get_postage_label, request)
shipment.log(response)
File.open('/tmp/endicia-response.xml', 'wb'){|f| f << response}
- parse_label_response(package, response, shipment.international?)
+ parse_label_response(package, response, shipment)
end
end
@@ -171,6 +171,10 @@ def build_label_request(shipment, package, verify=false)
if supports_epl2?(shipment)
label_request_options['ImageFormat'] = 'ZPLII'
label_request_options['ImageRotation'] = 'None'
+ elsif supports_international_epl2?(shipment)
+ label_request_options['LabelSize'] = '4x6c'
+ label_request_options['ImageFormat'] = 'ZPLII'
+ label_request_options['ImageRotation'] = 'None'
else
label_request_options['ImageFormat'] = 'PDF'
end
@@ -271,11 +275,13 @@ def add_location(xml, name, object)
end
end
- def parse_label_response(package, response, international=false)
+ def parse_label_response(package, response, shipment)
root = parse_response(response, 'LabelRequestResponse')
- if international
+ if shipment.international?
package.label = []
- root.elements['Label'].elements.each do |label|
+ labels = root.elements['Label'].elements
+ labels = labels.to_a.values_at(0,2) if supports_international_epl2?(shipment)
+ labels.each do |label|
package.label << Base64.decode64(label.text)
end
else
@@ -415,6 +421,10 @@ def supports_epl2?(shipment)
!shipment.international? || shipment.service == 'FirstClassMailInternational'
end
+ def supports_international_epl2?(shipment)
+ shipment.international? and shipment.service != 'FirstClassMailInternational'
+ end
+
def calculate_postage_rate
end
View
14 test/remote/endicia_test.rb
@@ -107,12 +107,24 @@ def test_buy_shipping_lable_for_mapped_countries_priority_international
end
end
- def test_buy_shipping_lable_for_mapped_countries_priority_internaional
+ def test_buy_shipping_lable_for_mapped_countries_priority_international
[:great_britain_customer].each do |country|
test_endicia_buy_shipping_label_request(@locations[country], @packages.values_at(:american_wii_insured), 'PriorityMailInternational')
end
end
+ def test_buy_shipping_lable_for_mapped_countries_first_class_mail_international
+ [:great_britain_customer].each do |country|
+ test_endicia_buy_shipping_label_request(@locations[country], @packages.values_at(:light_international), 'FirstClassMailInternational')
+ end
+ end
+
+ def test_buy_shipping_lable_for_mapped_countries_express_mail_international
+ [:great_britain_customer].each do |country|
+ test_endicia_buy_shipping_label_request(@locations[country], @packages.values_at(:american_wii_insured), 'ExpressMailInternational')
+ end
+ end
+
def test_buy_shipping_labels_for_priority_mail_to_fpo_address
test_endicia_buy_shipping_label_request(@locations[:fpo_customer], @packages.values_at(:american_wii_insured), 'Priority')
end
View
13 test/test_helper.rb
@@ -85,7 +85,18 @@ module TestFixtures
:big_half_pound => Package.new((16 * 50), [24,24,36], :units => :imperial),
:chocolate_stuff => Package.new(80, [2,6,12], :units => :imperial),
:shipping_container => Package.new(2200000, [2440, 2600, 6058], :description => '20 ft Standard Container', :units => :metric),
- :american_wii_insured => Package.new((7.5 * 16),
+ :light_international => Package.new((1 * 16),
+ [15, 10, 4.5],
+ :units => :imperial,
+ :reference_1 => 'OR7656789',
+ :reference_2 => 'PK829829 v1 10x5x3',
+ :unit_count => 1,
+ :value => Money.new(5000),
+ :customs_declarations => [CustomsDeclaration.new(:description=>'Consumer Electronics: Other', :quantity => 1, :weight_oz => (1 * 16), :value_cents => Money.new(5000))],
+ :currency => 'USD',
+ :cost => Money.new(5000),
+ :insured_value => Money.new(5000)),
+ :american_wii_insured => Package.new((7.5 * 16),
[15, 10, 4.5],
:units => :imperial,
:reference_1 => 'OR7656789',

0 comments on commit 2c23a0d

Please sign in to comment.
Something went wrong with that request. Please try again.