Skip to content

Commit 4658c0c

Browse files
author
Greg Taylor
committed
Merge pull request #24 from danielatdattrixdotcom/patch-1
Update rate example to show multiple ServiceTypes
2 parents 7109662 + 6917b45 commit 4658c0c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

examples/rate_request.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
# See page 355 in WS_ShipService.pdf for a full list. Here are the common ones:
2727
# STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, FEDEX_EXPRESS_SAVER
28+
# To receive rates for multiple ServiceTypes set to None.
2829
rate_request.RequestedShipment.ServiceType = 'FEDEX_GROUND'
2930

3031
# What kind of package this will be shipped in.
@@ -88,12 +89,14 @@
8889
# Here is the overall end result of the query.
8990
print "HighestSeverity:", rate_request.response.HighestSeverity
9091

91-
for detail in rate_request.response.RateReplyDetails[0].RatedShipmentDetails:
92-
for surcharge in detail.ShipmentRateDetail.Surcharges:
93-
if surcharge.SurchargeType == 'OUT_OF_DELIVERY_AREA':
94-
print "ODA rate_request charge %s" % surcharge.Amount.Amount
92+
# RateReplyDetails can contain rates for multiple ServiceTypes if ServiceType was set to None
93+
for service in rate_request.response.RateReplyDetails:
94+
for detail in service.RatedShipmentDetails:
95+
for surcharge in detail.ShipmentRateDetail.Surcharges:
96+
if surcharge.SurchargeType == 'OUT_OF_DELIVERY_AREA':
97+
print "%s: ODA rate_request charge %s" % (service.ServiceType, surcharge.Amount.Amount)
9598

96-
for rate_detail in rate_request.response.RateReplyDetails[0].RatedShipmentDetails:
97-
print "Net FedEx Charge %s %s" % (rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Currency,
98-
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Amount)
99+
for rate_detail in service.RatedShipmentDetails:
100+
print "%s: Net FedEx Charge %s %s" % (service.ServiceType, rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Currency,
101+
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Amount)
99102

0 commit comments

Comments
 (0)