Class: FriendlyShipping::Services::UspsInternational::SerializeRateRequest
- Inherits:
-
Object
- Object
- FriendlyShipping::Services::UspsInternational::SerializeRateRequest
- Defined in:
- lib/friendly_shipping/services/usps_international/serialize_rate_request.rb
Class Method Summary collapse
-
.call(shipment:, login:, options:) ⇒ Array<FriendlyShipping::Rate>
A set of Rates that this package may be sent with.
Class Method Details
.call(shipment:, login:, options:) ⇒ Array<FriendlyShipping::Rate>
Returns A set of Rates that this package may be sent with.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/friendly_shipping/services/usps_international/serialize_rate_request.rb', line 15 def call(shipment:, login:, options:) xml_builder = Nokogiri::XML::Builder.new do |xml| xml.IntlRateV2Request('USERID' => login) do xml.Revision("2") shipment.packages.each_with_index do |package, index| xml.Package('ID' => index) do xml.Pounds(pounds_for(package)) xml.Ounces(ounces_for(package)) xml.Machinable(machinable(package)) = .(package) xml.MailType(.mail_type) xml.ValueOfContents(package.items_value) xml.Country(shipment.destination.country) xml.Container(.container) if .transmit_dimensions && .container == 'VARIABLE' xml.Width("%<width>0.2f" % { width: package.width.convert_to(:inches).value.to_f }) xml.Length("%<length>0.2f" % { length: package.length.convert_to(:inches).value.to_f }) xml.Height("%<height>0.2f" % { height: package.height.convert_to(:inches).value.to_f }) # When girth is present, the package is treated as non-rectangular # when calculating dimensional weight. This results in a smaller # dimensional weight than a rectangular package would have. unless .rectangular xml.Girth("%<girth>0.2f" % { girth: girth(package) }) end xml.CommercialFlag(.commercial_pricing) xml.CommercialPlusFlag(.commercial_plus_pricing) end end end end end xml_builder.to_xml end |