Permalink
Browse files

Changed rate detail retrieval to check for more than one rate detail

  • Loading branch information...
jimmybaker committed Jan 24, 2012
1 parent 7bc4dce commit 0f751c5f778874ea0225270be504f96e6170cbbd
Showing with 46 additions and 43 deletions.
  1. +46 −43 lib/shippinglogic/fedex/ship.rb
@@ -167,7 +167,7 @@ class Shipment; attr_accessor :rate, :currency, :delivery_date, :tracking_number
# delivery options
attribute :ship_time, :datetime, :default => lambda { |shipment| Time.now }
- attribute :service_type, :string, :default => "INTERNATIONAL_PRIORITY"
+ attribute :service_type, :string, :default => "FEDEX_GROUND"
attribute :dropoff_type, :string, :default => "REGULAR_PICKUP"
attribute :special_services_requested, :array
attribute :signature, :string
@@ -229,48 +229,46 @@ def build_request
end
end
- b.CustomsClearanceDetail do
- b.DutiesPayment do
- b.PaymentType payment_type if payment_type
- b.Payor do
- b.AccountNumber payor_account_number if payor_account_number
- b.CountryCode payor_country if payor_country
- end
- end
- b.DocumentContent document_content if document_content
- b.CustomsValue do
- b.Currency currency if currency
- b.Amount item_amount if item_amount
- end
- b.CommercialInvoice do
- b.TermsOfSale terms_of_sale if terms_of_sale
- end
- b.Commodities do
- b.NumberOfPieces number_of_pieces if number_of_pieces
- b.Description description if description
- b.CountryOfManufacture country_of_manufacture if country_of_manufacture
- b.Weight do
- b.Units package_weight_units if package_weight_units
- b.Value package_weight if package_weight
- end
- b.Quantity quantity if quantity
- b.QuantityUnits quantity_units if quantity_units
- b.UnitPrice do
- b.Currency currency if currency
- b.Amount item_amount if item_amount
- end
- b.CustomsValue do
- b.Currency currency if currency
- b.Amount item_amount if item_amount
- end
- end
-
- unless export_compliance_statement.blank?
- b.ExportDetail do
- b.ExportComplianceStatement export_compliance_statement if export_compliance_statement
- end
- end
- end
+ # b.CustomsClearanceDetail do
+ # b.DutiesPayment do
+ # b.PaymentType payment_type if payment_type
+ # b.Payor do
+ # b.AccountNumber payor_account_number if payor_account_number
+ # b.CountryCode payor_country if payor_country
+ # end
+ # end
+ # b.DocumentContent document_content if document_content
+ # b.CustomsValue do
+ # b.Currency currency if currency
+ # b.Amount item_amount if item_amount
+ # end
+ # # b.CommercialInvoice do
+ # # b.TermsOfSale terms_of_sale if terms_of_sale
+ # # end
+ # b.Commodities do
+ # b.NumberOfPieces number_of_pieces if number_of_pieces
+ # b.Description description if description
+ # b.CountryOfManufacture country_of_manufacture if country_of_manufacture
+ # b.Weight do
+ # b.Units package_weight_units if package_weight_units
+ # b.Value package_weight if package_weight
+ # end
+ # b.Quantity quantity if quantity
+ # b.QuantityUnits quantity_units if quantity_units
+ # b.UnitPrice do
+ # b.Currency currency if currency
+ # b.Amount item_amount if item_amount
+ # end
+ # b.CustomsValue do
+ # b.Currency currency if currency
+ # b.Amount item_amount if item_amount
+ # end
+ # end
+ #
+ # b.ExportDetail do
+ # b.ExportComplianceStatement export_compliance_statement if export_compliance_statement
+ # end
+ # end
b.LabelSpecification do
b.LabelFormatType label_format if label_format
@@ -287,7 +285,12 @@ def build_request
# Making sense of the reponse and grabbing the information we need.
def parse_response(response)
details = response[:completed_shipment_detail]
+
+ # Returning the first shipment_rate_details, if more than one are returned.
+ # This will be the PAYOR details
rate_details = details[:shipment_rating][:shipment_rate_details]
+ rate_details = rate_details.kind_of?(Array) ? rate_details.first : rate_details
+
rate = rate_details[:total_net_charge] || rate_details.first[:total_net_charge]
package_details = details[:completed_package_details]

0 comments on commit 0f751c5

Please sign in to comment.