Skip to content

Commit ef73a90

Browse files
committed
Updated rate_request and freight_rate_request examples for WSDL v16 compatibility, removed extraneous whitespace
1 parent bbcc57b commit ef73a90

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

examples/freight_rate_request.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/env python
22
"""
3-
This example shows how to use the FedEx RateRequest service.
4-
The variables populated below represents the minimum required values.
5-
You will need to fill all of these, or risk seeing a SchemaValidationError
3+
This example shows how to use the FedEx RateRequest service.
4+
The variables populated below represents the minimum required values.
5+
You will need to fill all of these, or risk seeing a SchemaValidationError
66
exception thrown by suds.
77
8-
TIP: Near the bottom of the module, see how to check the if the destination
8+
TIP: Near the bottom of the module, see how to check the if the destination
99
is Out of Delivery Area (ODA).
1010
"""
1111
import logging
@@ -19,7 +19,7 @@
1919
# We're using the FedexConfig object from example_config.py in this dir.
2020
rate_request = FedexRateServiceRequest(CONFIG_OBJ)
2121

22-
rate_request.RequestedShipment.ServiceType = 'FEDEX_FREIGHT'
22+
rate_request.RequestedShipment.ServiceType = 'FEDEX_FREIGHT_ECONOMY'
2323

2424
rate_request.RequestedShipment.DropoffType = 'REGULAR_PICKUP'
2525

@@ -42,11 +42,7 @@
4242
#include estimated duties and taxes in rate quote, can be ALL or NONE
4343
rate_request.RequestedShipment.EdtRequestType = 'NONE'
4444

45-
rate_request.RequestedShipment.PackageDetail = 'PACKAGE_SUMMARY'
46-
47-
rate_request.RequestedShipment.FreightShipmentDetail.PaymentType = 'PREPAID'
48-
49-
# note: in order for this to work in test, you may need to use the
45+
# note: in order for this to work in test, you may need to use the
5046
# specially provided LTL addresses emailed to you when signing up.
5147
rate_request.RequestedShipment.FreightShipmentDetail.FedExFreightBillingContactAndAddress.Contact.PersonName = 'Sender Name'
5248
rate_request.RequestedShipment.FreightShipmentDetail.FedExFreightBillingContactAndAddress.Contact.CompanyName = 'Some Company'
@@ -65,9 +61,12 @@
6561
rate_request.RequestedShipment.ShippingDocumentSpecification = spec
6662

6763
role = rate_request.create_wsdl_object_of_type('FreightShipmentRoleType')
68-
6964
rate_request.RequestedShipment.FreightShipmentDetail.Role = role.SHIPPER
7065

66+
# Designates the terms of the "collect" payment for a Freight
67+
#Shipment. Can be NON_RECOURSE_SHIPPER_SIGNED or STANDARD
68+
rate_request.RequestedShipment.FreightShipmentDetail.CollectTermsType = 'STANDARD'
69+
7170
package1_weight = rate_request.create_wsdl_object_of_type('Weight')
7271
package1_weight.Value = 500.0
7372
package1_weight.Units = "LB"
@@ -108,7 +107,7 @@
108107
for surcharge in detail.ShipmentRateDetail.Surcharges:
109108
if surcharge.SurchargeType == 'OUT_OF_DELIVERY_AREA':
110109
print "%s: ODA rate_request charge %s" % (service.ServiceType, surcharge.Amount.Amount)
111-
110+
112111
for rate_detail in service.RatedShipmentDetails:
113112
print "%s: Net FedEx Charge %s %s" % (service.ServiceType, rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Currency,
114113
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Amount)

examples/rate_request.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/env python
22
"""
3-
This example shows how to use the FedEx RateRequest service.
4-
The variables populated below represents the minimum required values.
5-
You will need to fill all of these, or risk seeing a SchemaValidationError
3+
This example shows how to use the FedEx RateRequest service.
4+
The variables populated below represents the minimum required values.
5+
You will need to fill all of these, or risk seeing a SchemaValidationError
66
exception thrown by suds.
77
8-
TIP: Near the bottom of the module, see how to check the if the destination
8+
TIP: Near the bottom of the module, see how to check the if the destination
99
is Out of Delivery Area (ODA).
1010
"""
1111
import logging
@@ -36,10 +36,6 @@
3636
# FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING
3737
rate_request.RequestedShipment.PackagingType = 'YOUR_PACKAGING'
3838

39-
# No idea what this is.
40-
# INDIVIDUAL_PACKAGES, PACKAGE_GROUPS, PACKAGE_SUMMARY
41-
rate_request.RequestedShipment.PackageDetail = 'INDIVIDUAL_PACKAGES'
42-
4339
# Shipper's address
4440
rate_request.RequestedShipment.Shipper.Address.PostalCode = '29631'
4541
rate_request.RequestedShipment.Shipper.Address.CountryCode = 'US'
@@ -55,8 +51,8 @@
5551

5652
# Who pays for the rate_request?
5753
# RECIPIENT, SENDER or THIRD_PARTY
58-
rate_request.RequestedShipment.ShippingChargesPayment.PaymentType = 'SENDER'
59-
rate_request.RequestedShipment.ShippingChargesPayment.Payor.AccountNumber = CONFIG_OBJ.account_number
54+
rate_request.RequestedShipment.ShippingChargesPayment.PaymentType = 'SENDER'
55+
6056
package1_weight = rate_request.create_wsdl_object_of_type('Weight')
6157
# Weight, in LB.
6258
package1_weight.Value = 1.0
@@ -66,6 +62,10 @@
6662
package1.Weight = package1_weight
6763
#can be other values this is probably the most common
6864
package1.PhysicalPackaging = 'BOX'
65+
# Required, but according to FedEx docs:
66+
# "Used only with PACKAGE_GROUPS, as a count of packages within a
67+
# group of identical packages" whatever that means
68+
package1.GroupPackageCount = 1
6969
# Un-comment this to see the other variables you may set on a package.
7070
#print package1
7171

@@ -99,7 +99,7 @@
9999
for surcharge in detail.ShipmentRateDetail.Surcharges:
100100
if surcharge.SurchargeType == 'OUT_OF_DELIVERY_AREA':
101101
print "%s: ODA rate_request charge %s" % (service.ServiceType, surcharge.Amount.Amount)
102-
102+
103103
for rate_detail in service.RatedShipmentDetails:
104104
print "%s: Net FedEx Charge %s %s" % (service.ServiceType, rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Currency,
105105
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Amount)

0 commit comments

Comments
 (0)