Skip to content

Commit 1b94b75

Browse files
committed
refactor naming, update documentation
1 parent 012fbaf commit 1b94b75

9 files changed

+91
-82
lines changed

fedex/__init__.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
2121
A note on completeness
2222
----------------------
23-
python-fedex was created for use with some of my internal projects. For the
24-
initial release, only the things that I needed at the time were implemented.
23+
python-fedex was created for use with various internal projects over the years.
24+
Not all services are implemented but only those needed at the time were implemented.
2525
If there is missing functionality, please report an U{issue<http://code.google.com/p/python-fedex/issues/list>}
26-
so that I may make this module more useful to others. Likewise, feel free to
27-
submit patches as well if you would like to help.
26+
so that this module can be made more useful to others. Likewise, feel free to
27+
submit patches and service implementations as well if you would like to help.
2828
2929
Getting Started
3030
---------------
@@ -49,7 +49,7 @@
4949
Getting Support
5050
---------------
5151
If you have any questions, problems, ideas, or patch submissions, please visit
52-
our U{Google Code project<http://code.google.com/p/python-fedex/>} and enter
53-
an issue in the U{Issue Tracker<http://code.google.com/p/python-fedex/issues/list>}.
52+
our U{Github project<http://github.com/gtaylor/python-fedex/>} and enter
53+
an issue in the U{Issue Tracker<http://github.com/gtaylor/python-fedex/issues>}.
5454
"""
55-
VERSION = __version__ = '2.1.0'
55+
VERSION = __version__ = '2.2.0'

fedex/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(self, key, password, account_number=None, meter_number=None, freigh
6262
self.integrator_id = integrator_id
6363
"""@ivar: Web services integrator ID."""
6464
self.express_region_code = express_region_code
65-
"""@icar: Web services ExpressRegionCode"""
65+
"""@ivar: Web services ExpressRegionCode"""
6666
self.use_test_server = use_test_server
6767
"""@ivar: When True, point to the test server."""
6868

fedex/services/address_validation_service.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Address Validation Service Module
3-
=================================
3+
44
This package contains the shipping methods defined by Fedex's
55
AddressValidationService WSDL file. Each is encapsulated in a class for
66
easy access. For more details on each, refer to the respective class's
@@ -33,7 +33,6 @@ def __init__(self, config_obj, *args, **kwargs):
3333
'minor': '0'
3434
}
3535

36-
"""@ivar: Holds the AddressValidationOptions WSDL object."""
3736
self.AddressesToValidate = []
3837
"""@ivar: Holds the AddressToValidate WSDL object."""
3938
# Call the parent FedexBaseService class for basic setup work.

fedex/services/availability_commitment_service.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Service Availability and Commitment Module
3-
=================================
3+
44
This package contains the shipping methods defined by Fedex's
55
ValidationAvailabilityAndCommitmentService WSDL file. Each is encapsulated in a class for
66
easy access. For more details on each, refer to the respective class's
@@ -31,21 +31,29 @@ def __init__(self, config_obj, *args, **kwargs):
3131
'minor': '0'
3232
}
3333

34-
"""ivar: Carrier Code Default to Fedex (FDXE), or can bbe FDXG."""
3534
self.CarrierCode = None
35+
"""ivar: Carrier Code Default to Fedex (FDXE), or can bbe FDXG."""
36+
37+
self.Origin = None
38+
"""@ivar: Holds Origin Address WSDL object."""
39+
40+
self.Destination = None
41+
"""@ivar: Holds Destination Address WSDL object."""
3642

37-
"""@ivar: Holds Addresses, Ship Date, Service and Packaging objects."""
38-
self.Origin = self.Destination = None
3943
self.ShipDate = None
44+
"""@ivar: Ship Date date WSDL object."""
45+
4046
self.Service = None
47+
"""@ivar: Service type, if set to None will get all available service information."""
48+
4149
self.Packaging = None
50+
"""@ivar: Type of packaging to narrow down available shipping options or defaults to YOUR_PACKAGING."""
4251

43-
"""@ivar: Holds the ValidationAvailabilityAndCommitmentService WSDL object."""
4452
# Call the parent FedexBaseService class for basic setup work.
4553
# Shortened the name of the wsdl, otherwise suds did not load it properly.
4654
# Suds throws the following error when using the long file name from FedEx:
4755
#
48-
# File "/Library/Python/2.7/site-packages/suds/wsdl.py", line 878, in resolve
56+
# File "/Library/Python/2.7/site-packages/suds/wsdl.py", line 878, in resolve
4957
# raise Exception("binding '%s', not-found" % p.binding)
5058
# Exception: binding 'ns:ValidationAvailabilityAndCommitmentServiceSoapBinding', not-found
5159

fedex/services/country_service.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Country Service Module
3-
=================================
3+
44
This package contains the shipping methods defined by Fedex's
55
CountryService WSDL file. Each is encapsulated in a class for
66
easy access. For more details on each, refer to the respective class's
@@ -13,7 +13,8 @@
1313

1414
class FedexValidatePostalRequest(FedexBaseService):
1515
"""
16-
This class allows you validate service availability
16+
This class allows you validate an address.
17+
https://www.fedex.com/us/developer/WebHelp/ws/2015/html/WebServicesHelp/WSDVG/47_Country_Service.htm
1718
"""
1819

1920
def __init__(self, config_obj, *args, **kwargs):
@@ -31,18 +32,21 @@ def __init__(self, config_obj, *args, **kwargs):
3132
'minor': '0'
3233
}
3334

34-
"""ivar: Carrier Code Default to Fedex (FDXE), or can bbe FDXG."""
3535
self.CarrierCode = None
36+
"""ivar: Carrier Code Default to Fedex (FDXE), or can bbe FDXG."""
3637

37-
"""ivar: Routing Code Default to FDSD"""
3838
self.RoutingCode = None
39+
"""ivar: Routing Code Default to FDSD."""
3940

40-
"""@ivar: Holds Addresses, Ship Date, Service and Packaging objects."""
4141
self.Address = None
42+
"""@ivar: Holds Address WSDL objects."""
43+
4244
self.ShipDateTime = None
45+
"""@ivar: Holds the ShipDateTime date time objects."""
46+
4347
self.CheckForMismatch = 1
48+
"""@ivar: Holds the CheckForMismatch boolean objects."""
4449

45-
"""@ivar: Holds the ValidationAvailabilityAndCommitmentService WSDL object."""
4650
super(FedexValidatePostalRequest, self).__init__(
4751
self._config_obj, 'CountryService_v4.wsdl', *args, **kwargs)
4852

fedex/services/package_movement.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Package Movement Information Service
3-
====================================
3+
44
This package contains classes to check service availability, route, and postal
55
codes. Defined by the PackageMovementInformationService WSDL file.
66
"""

fedex/services/rate_service.py

+21-23
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Rate Service Module
3-
===================
3+
44
This package contains classes to request pre-ship rating information and to
55
determine estimated or courtesy billing quotes. Time in Transit can be
66
returned with the rates if it is specified in the request.
@@ -33,12 +33,12 @@ def __init__(self, config_obj, *args, **kwargs):
3333
'intermediate': '0', 'minor': '0'}
3434

3535
self.RequestedShipment = None
36-
"""@ivar: Holds the RequestedShipment WSDL object."""
36+
"""@ivar: Holds the RequestedShipment WSDL object including the shipper, recipient and shipt time."""
3737
# Call the parent FedexBaseService class for basic setup work.
38-
super(FedexRateServiceRequest, self).__init__(self._config_obj,
39-
'RateService_v18.wsdl',
40-
*args, **kwargs)
38+
super(FedexRateServiceRequest, self).__init__(
39+
self._config_obj, 'RateService_v18.wsdl', *args, **kwargs)
4140
self.ClientDetail.Region = config_obj.express_region_code
41+
"""@ivar: Holds the express region code from the config object."""
4242

4343
def _prepare_wsdl_objects(self):
4444
"""
@@ -53,36 +53,34 @@ def _prepare_wsdl_objects(self):
5353
self.RequestedShipment = self.client.factory.create('RequestedShipment')
5454
self.RequestedShipment.ShipTimestamp = datetime.datetime.now()
5555

56-
TotalWeight = self.client.factory.create('Weight')
56+
# Defaults for TotalWeight wsdl object.
57+
total_weight = self.client.factory.create('Weight')
5758
# Start at nothing.
58-
TotalWeight.Value = 0.0
59+
total_weight.Value = 0.0
5960
# Default to pounds.
60-
TotalWeight.Units = 'LB'
61+
total_weight.Units = 'LB'
6162
# This is the total weight of the entire shipment. Shipments may
6263
# contain more than one package.
63-
self.RequestedShipment.TotalWeight = TotalWeight
64+
self.RequestedShipment.TotalWeight = total_weight
6465

6566
# This is the top level data structure for Shipper information.
66-
ShipperParty = self.client.factory.create('Party')
67-
ShipperParty.Address = self.client.factory.create('Address')
68-
ShipperParty.Contact = self.client.factory.create('Contact')
67+
shipper = self.client.factory.create('Party')
68+
shipper.Address = self.client.factory.create('Address')
69+
shipper.Contact = self.client.factory.create('Contact')
6970

7071
# Link the ShipperParty to our master data structure.
71-
self.RequestedShipment.Shipper = ShipperParty
72+
self.RequestedShipment.Shipper = shipper
7273

7374
# This is the top level data structure for Recipient information.
74-
RecipientParty = self.client.factory.create('Party')
75-
RecipientParty.Contact = self.client.factory.create('Contact')
76-
RecipientParty.Address = self.client.factory.create('Address')
77-
75+
recipient_party = self.client.factory.create('Party')
76+
recipient_party.Contact = self.client.factory.create('Contact')
77+
recipient_party.Address = self.client.factory.create('Address')
7878
# Link the RecipientParty object to our master data structure.
79-
self.RequestedShipment.Recipient = RecipientParty
79+
self.RequestedShipment.Recipient = recipient_party
8080

81-
Payor = self.client.factory.create('Payor')
82-
# Grab the account number from the FedexConfig object by default.
83-
Payor.AccountNumber = self._config_obj.account_number
84-
# Assume US.
85-
Payor.CountryCode = 'US'
81+
# Make sender responsible for payment by default.
82+
self.RequestedShipment.ShippingChargesPayment = self.create_wsdl_object_of_type('Payment')
83+
self.RequestedShipment.ShippingChargesPayment.PaymentType = 'SENDER'
8684

8785
# Start with no packages, user must add them.
8886
self.RequestedShipment.PackageCount = 0

fedex/services/ship_service.py

+26-24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Ship Service Module
3-
===================
3+
44
This package contains the shipping methods defined by Fedex's
55
ShipService WSDL file. Each is encapsulated in a class for easy access.
66
For more details on each, refer to the respective class's documentation.
@@ -51,43 +51,45 @@ def _prepare_wsdl_objects(self):
5151
self.RequestedShipment = self.client.factory.create('RequestedShipment')
5252
self.RequestedShipment.ShipTimestamp = datetime.datetime.now()
5353

54-
TotalWeight = self.client.factory.create('Weight')
54+
# Defaults for TotalWeight wsdl object.
55+
total_weight = self.client.factory.create('Weight')
5556
# Start at nothing.
56-
TotalWeight.Value = 0.0
57+
total_weight.Value = 0.0
5758
# Default to pounds.
58-
TotalWeight.Units = 'LB'
59+
total_weight.Units = 'LB'
5960
# This is the total weight of the entire shipment. Shipments may
6061
# contain more than one package.
61-
self.RequestedShipment.TotalWeight = TotalWeight
62+
self.RequestedShipment.TotalWeight = total_weight
6263

63-
# This is the top level data structure for Shipper information.
64-
ShipperParty = self.client.factory.create('Party')
65-
ShipperParty.Address = self.client.factory.create('Address')
66-
ShipperParty.Contact = self.client.factory.create('Contact')
64+
# This is the top level data structure Shipper Party information.
65+
shipper_party = self.client.factory.create('Party')
66+
shipper_party.Address = self.client.factory.create('Address')
67+
shipper_party.Contact = self.client.factory.create('Contact')
6768

68-
# Link the ShipperParty to our master data structure.
69-
self.RequestedShipment.Shipper = ShipperParty
69+
# Link the Shipper Party to our master data structure.
70+
self.RequestedShipment.Shipper = shipper_party
7071

71-
# This is the top level data structure for Recipient information.
72-
RecipientParty = self.client.factory.create('Party')
73-
RecipientParty.Contact = self.client.factory.create('Contact')
74-
RecipientParty.Address = self.client.factory.create('Address')
72+
# This is the top level data structure for RecipientParty information.
73+
recipient_party = self.client.factory.create('Party')
74+
recipient_party.Contact = self.client.factory.create('Contact')
75+
recipient_party.Address = self.client.factory.create('Address')
7576

7677
# Link the RecipientParty object to our master data structure.
77-
self.RequestedShipment.Recipient = RecipientParty
78+
self.RequestedShipment.Recipient = recipient_party
7879

79-
Payor = self.client.factory.create('Payor')
80+
payor = self.client.factory.create('Payor')
8081
# Grab the account number from the FedexConfig object by default.
8182
# Assume US.
82-
Payor.ResponsibleParty = self.client.factory.create('Party')
83-
Payor.ResponsibleParty.Address = self.client.factory.create('Address')
84-
Payor.ResponsibleParty.Address.CountryCode = 'US'
83+
payor.ResponsibleParty = self.client.factory.create('Party')
84+
payor.ResponsibleParty.Address = self.client.factory.create('Address')
85+
payor.ResponsibleParty.Address.CountryCode = 'US'
8586

86-
ShippingChargesPayment = self.client.factory.create('Payment')
87-
ShippingChargesPayment.Payor = Payor
88-
ShippingChargesPayment.PaymentType = 'SENDER'
87+
# ShippingChargesPayment WSDL object default values.
88+
shipping_charges_payment = self.client.factory.create('Payment')
89+
shipping_charges_payment.Payor = payor
90+
shipping_charges_payment.PaymentType = 'SENDER'
91+
self.RequestedShipment.ShippingChargesPayment = shipping_charges_payment
8992

90-
self.RequestedShipment.ShippingChargesPayment = ShippingChargesPayment
9193
self.RequestedShipment.LabelSpecification = self.client.factory.create('LabelSpecification')
9294

9395
# NONE, PREFERRED or LIST

fedex/services/track_service.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Tracking Service Module
3-
=======================
3+
44
This package contains the shipment tracking methods defined by Fedex's
55
TrackService WSDL file. Each is encapsulated in a class for easy access.
66
For more details on each, refer to the respective class's documentation.
@@ -34,9 +34,6 @@ def __init__(self, config_obj, *args, **kwargs):
3434
3535
@type config_obj: L{FedexConfig}
3636
@param config_obj: A valid FedexConfig object.
37-
38-
@type tracking_number_unique_id: str
39-
@param tracking_number_unique_id: Used to distinguish duplicate FedEx tracking numbers.
4037
"""
4138

4239
self._config_obj = config_obj
@@ -49,7 +46,11 @@ def __init__(self, config_obj, *args, **kwargs):
4946
'minor': '0'
5047
}
5148
self.SelectionDetails = None
52-
"""@ivar: Holds the TrackPackageIdentifier WSDL object."""
49+
"""@ivar: Holds the SelectionDetails WSDL object that includes tracking type and value."""
50+
51+
# Set Default as None. 'INCLUDE_DETAILED_SCANS' or None
52+
self.ProcessingOptions = None
53+
"""@ivar: Holds the TrackRequestProcessingOptionType WSDL object that defaults no None."""
5354

5455
# Call the parent FedexBaseService class for basic setup work.
5556
super(FedexTrackRequest, self).__init__(
@@ -67,15 +68,12 @@ def _prepare_wsdl_objects(self):
6768
# Default to Fedex
6869
self.SelectionDetails.CarrierCode = 'FDXE'
6970

70-
TrackPackageIdentifier = self.client.factory.create('TrackPackageIdentifier')
71+
track_package_id = self.client.factory.create('TrackPackageIdentifier')
7172

7273
# Default to tracking number.
73-
TrackPackageIdentifier.Type = 'TRACKING_NUMBER_OR_DOORTAG'
74-
75-
self.SelectionDetails.PackageIdentifier = TrackPackageIdentifier
74+
track_package_id.Type = 'TRACKING_NUMBER_OR_DOORTAG'
7675

77-
# Set Default as None. 'INCLUDE_DETAILED_SCANS' or None
78-
self.TrackRequestProcessingOptionType = None
76+
self.SelectionDetails.PackageIdentifier = track_package_id
7977

8078
def _check_response_for_request_errors(self):
8179
"""
@@ -107,4 +105,4 @@ def _assemble_and_send_request(self):
107105
TransactionDetail=self.TransactionDetail,
108106
Version=self.VersionId,
109107
SelectionDetails=self.SelectionDetails,
110-
ProcessingOptions=self.TrackRequestProcessingOptionType)
108+
ProcessingOptions=self.ProcessingOptions)

0 commit comments

Comments
 (0)