Skip to content

Commit f2cf70a

Browse files
committed
Merge pull request #33 from foxxyz/master
Updated RateRequest WSDL from v8 to v16
2 parents 8edc332 + ef73a90 commit f2cf70a

File tree

6 files changed

+9764
-9530
lines changed

6 files changed

+9764
-9530
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)

fedex/base_service.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,13 @@ class SchemaValidationError(FedexBaseServiceException):
4141
"""
4242
Exception: There is probably a problem in the data you provided.
4343
"""
44-
def __init__(self):
44+
def __init__(self, fault):
4545
self.error_code = -1
4646
self.value = "suds encountered an error validating your data against this service's WSDL schema. Please double-check for missing or invalid values, filling all required fields."
47+
try:
48+
self.value += ' Details: {}'.format(fault.detail.desc)
49+
except AttributeError:
50+
pass
4751

4852
class FedexBaseService(object):
4953
"""
@@ -212,11 +216,11 @@ def send_request(self, send_function=None):
212216
else:
213217
# Default scenario, business as usual.
214218
self.response = self._assemble_and_send_request()
215-
except suds.WebFault:
219+
except suds.WebFault as fault:
216220
# When this happens, throw an informative message reminding the
217221
# user to check all required variables, making sure they are
218-
# populated and valid.
219-
raise SchemaValidationError()
222+
# populated and valid
223+
raise SchemaValidationError(fault.fault)
220224

221225
# Check the response for general Fedex errors/failures that aren't
222226
# specific to any given WSDL/request.

fedex/services/rate_service.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ def __init__(self, config_obj, *args, **kwargs):
2525
self._config_obj = config_obj
2626

2727
# Holds version info for the VersionId SOAP object.
28-
self._version_info = {'service_id': 'crs', 'major': '8',
28+
self._version_info = {'service_id': 'crs', 'major': '16',
2929
'intermediate': '0', 'minor': '0'}
3030

3131
self.RequestedShipment = None
3232
"""@ivar: Holds the RequestedShipment WSDL object."""
3333
# Call the parent FedexBaseService class for basic setup work.
3434
super(FedexRateServiceRequest, self).__init__(self._config_obj,
35-
'RateService_v8.wsdl',
35+
'RateService_v16.wsdl',
3636
*args, **kwargs)
3737
self.ClientDetail.Region = config_obj.express_region_code
3838

@@ -80,9 +80,6 @@ def _prepare_wsdl_objects(self):
8080
# Assume US.
8181
Payor.CountryCode = 'US'
8282

83-
# ACCOUNT or LIST
84-
self.RequestedShipment.RateRequestTypes = ['ACCOUNT']
85-
8683
# Start with no packages, user must add them.
8784
self.RequestedShipment.PackageCount = 0
8885
self.RequestedShipment.RequestedPackageLineItems = []

0 commit comments

Comments
 (0)