Skip to content

Commit 2900950

Browse files
committed
added avc service, updated version, readme, change log
1 parent 9a69aa8 commit 2900950

File tree

8 files changed

+1010
-14
lines changed

8 files changed

+1010
-14
lines changed

CHANGES.rst

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
Change Log
22
==========
33

4+
2.1.0
5+
-----
6+
7+
* Added Validation, Availability and Commitment (AVC) service. (radzhome)
8+
* Added [Validation]AvailabilityAndCommitmentService_v4.wsdl for AVC service. (radzhome)
9+
* Added examples and unit tests for AVC service.
10+
* Refactored examples and documentation. (radzhome)
11+
12+
413
2.0.0
514
-----
615

7-
* Bump ShipService WSDL to v17 for create and delete shipment. (radlws)
8-
* Bump AddressValidation WSDL to v4. (radlws)
9-
* Bump RateService WSDL to v18. (radlws)
10-
* Bump TrackService WSDL to v10. (radlws)
11-
* General improvements to base class. (radlws)
12-
* Refactoring and updates to examples. (radlws)
13-
* Added test classes. (radlws)
14-
* Remove old and unused WSDLs. (radlws)
15-
* Change dependency to suds-jurko to include python 3 support. (radlws)
16+
* Bump ShipService WSDL to v17 for create and delete shipment. (radzhome)
17+
* Bump AddressValidation WSDL to v4. (radzhome)
18+
* Bump RateService WSDL to v18. (radzhome)
19+
* Bump TrackService WSDL to v10. (radzhome)
20+
* General improvements to base class. (radzhome)
21+
* Refactoring and updates to examples. (radzhome)
22+
* Added test classes. (radzhome)
23+
* Remove old and unused WSDLs. (radzhome)
24+
* Change dependency to suds-jurko to include python 3 support. (radzhome)
1625

1726
1.1.1
1827
-----
@@ -24,7 +33,7 @@ Change Log
2433
-----
2534

2635
* A quick PEP8 pass on most of the codebase. Yucky. (gtaylor)
27-
* Changing recommended install method to use pip + PyPi. (radlws)
36+
* Changing recommended install method to use pip + PyPi. (radzhome)
2837
* Updated rate_request and freight_rate_request examples for WSDL v16
2938
compatibility. (foxxyz)
3039
* Updated rate service WSDL from v8 to v16. (foxxyz)

README.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Python FedEx SOAP API Module
44
:Author: Greg Taylor
55
:License: BSD
66
:Status: Stable
7-
:Maintained: Quasi-maintained, looking for new maintainer
87

98
What is it?
109
-----------
@@ -49,8 +48,8 @@ Fedex Support and Documentation
4948
Fedex Support Email: websupport@fedex.com
5049
Developer Portal: http://www.fedex.com/us/developer/
5150

52-
Legal Mumbo Jumbo
53-
-----------------
51+
Legal
52+
-----
5453

5554
Copyright (C) 2015 Gregory Taylor
5655

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#!/usr/bin/env python
2+
"""
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
6+
exception thrown by suds.
7+
8+
TIP: Near the bottom of the module, see how to check the if the destination
9+
is Out of Delivery Area (ODA).
10+
"""
11+
import logging
12+
from example_config import CONFIG_OBJ
13+
from fedex.services.rate_service import FedexRateServiceRequest
14+
15+
# Set this to the INFO level to see the response from Fedex printed in stdout.
16+
logging.basicConfig(level=logging.INFO)
17+
18+
19+
# This is the object that will be handling our tracking request.
20+
# We're using the FedexConfig object from example_config.py in this dir.
21+
customer_transaction_id = "*** RateService Request v18 using Python ***" # Optional transaction_id
22+
rate_request = FedexRateServiceRequest(CONFIG_OBJ, customer_transaction_id=customer_transaction_id)
23+
24+
# If you wish to have transit data returned with your request you
25+
# need to uncomment the following
26+
# rate_request.ReturnTransitAndCommit = True
27+
28+
# This is very generalized, top-level information.
29+
# REGULAR_PICKUP, REQUEST_COURIER, DROP_BOX, BUSINESS_SERVICE_CENTER or STATION
30+
rate_request.RequestedShipment.DropoffType = 'REGULAR_PICKUP'
31+
32+
# See page 355 in WS_ShipService.pdf for a full list. Here are the common ones:
33+
# STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, FEDEX_EXPRESS_SAVER
34+
# To receive rates for multiple ServiceTypes set to None.
35+
rate_request.RequestedShipment.ServiceType = 'FEDEX_GROUND'
36+
37+
# What kind of package this will be shipped in.
38+
# FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING
39+
rate_request.RequestedShipment.PackagingType = 'YOUR_PACKAGING'
40+
41+
# Shipper's address
42+
rate_request.RequestedShipment.Shipper.Address.PostalCode = '29631'
43+
rate_request.RequestedShipment.Shipper.Address.CountryCode = 'US'
44+
rate_request.RequestedShipment.Shipper.Address.Residential = False
45+
46+
# Recipient address
47+
rate_request.RequestedShipment.Recipient.Address.PostalCode = '27577'
48+
rate_request.RequestedShipment.Recipient.Address.CountryCode = 'US'
49+
# This is needed to ensure an accurate rate quote with the response.
50+
#rate_request.RequestedShipment.Recipient.Address.Residential = True
51+
#include estimated duties and taxes in rate quote, can be ALL or NONE
52+
rate_request.RequestedShipment.EdtRequestType = 'NONE'
53+
54+
# Who pays for the rate_request?
55+
# RECIPIENT, SENDER or THIRD_PARTY
56+
rate_request.RequestedShipment.ShippingChargesPayment.PaymentType = 'SENDER'
57+
58+
package1_weight = rate_request.create_wsdl_object_of_type('Weight')
59+
# Weight, in LB.
60+
package1_weight.Value = 1.0
61+
package1_weight.Units = "LB"
62+
63+
package1 = rate_request.create_wsdl_object_of_type('RequestedPackageLineItem')
64+
package1.Weight = package1_weight
65+
#can be other values this is probably the most common
66+
package1.PhysicalPackaging = 'BOX'
67+
# Required, but according to FedEx docs:
68+
# "Used only with PACKAGE_GROUPS, as a count of packages within a
69+
# group of identical packages". In practice you can use this to get rates
70+
# for a shipment with multiple packages of an identical package size/weight
71+
# on rate request without creating multiple RequestedPackageLineItem elements.
72+
# You can OPTIONALLY specify a package group:
73+
# package1.GroupNumber = 0 # default is 0
74+
# The result will be found in RatedPackageDetail, with specified GroupNumber.
75+
package1.GroupPackageCount = 1
76+
# Un-comment this to see the other variables you may set on a package.
77+
#print(package1)
78+
79+
# This adds the RequestedPackageLineItem WSDL object to the rate_request. It
80+
# increments the package count and total weight of the rate_request for you.
81+
rate_request.add_package(package1)
82+
83+
# If you'd like to see some documentation on the ship service WSDL, un-comment
84+
# this line. (Spammy).
85+
#print(rate_request.client)
86+
87+
# Un-comment this to see your complete, ready-to-send request as it stands
88+
# before it is actually sent. This is useful for seeing what values you can
89+
# change.
90+
#print(rate_request.RequestedShipment)
91+
92+
# Fires off the request, sets the 'response' attribute on the object.
93+
rate_request.send_request()
94+
95+
# This will show the reply to your rate_request being sent. You can access the
96+
# attributes through the response attribute on the request object. This is
97+
# good to un-comment to see the variables returned by the FedEx reply.
98+
#print(rate_request.response)
99+
100+
# Here is the overall end result of the query.
101+
print("HighestSeverity:", rate_request.response.HighestSeverity)
102+
103+
# RateReplyDetails can contain rates for multiple ServiceTypes if ServiceType was set to None
104+
for service in rate_request.response.RateReplyDetails:
105+
for detail in service.RatedShipmentDetails:
106+
for surcharge in detail.ShipmentRateDetail.Surcharges:
107+
if surcharge.SurchargeType == 'OUT_OF_DELIVERY_AREA':
108+
print("%s: ODA rate_request charge %s" % (service.ServiceType, surcharge.Amount.Amount))
109+
110+
for rate_detail in service.RatedShipmentDetails:
111+
print("%s: Net FedEx Charge %s %s" % (service.ServiceType,
112+
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Currency,
113+
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Amount))
114+

fedex/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@
5252
our U{Google Code project<http://code.google.com/p/python-fedex/>} and enter
5353
an issue in the U{Issue Tracker<http://code.google.com/p/python-fedex/issues/list>}.
5454
"""
55-
VERSION = __version__ = '2.0.0'
55+
VERSION = __version__ = '2.1.0'
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
"""
2+
Address Validation Service Module
3+
=================================
4+
This package contains the shipping methods defined by Fedex's
5+
AddressValidationService WSDL file. Each is encapsulated in a class for
6+
easy access. For more details on each, refer to the respective class's
7+
documentation.
8+
"""
9+
10+
from datetime import datetime
11+
from .. base_service import FedexBaseService
12+
13+
14+
class FedexAddressValidationRequest(FedexBaseService):
15+
"""
16+
This class allows you validate anywhere from one to a hundred addresses
17+
in one go. Create AddressToValidate WSDL objects and add them to each
18+
instance of this request using add_address().
19+
"""
20+
21+
def __init__(self, config_obj, *args, **kwargs):
22+
"""
23+
@type config_obj: L{FedexConfig}
24+
@param config_obj: A valid FedexConfig object.
25+
"""
26+
27+
self._config_obj = config_obj
28+
# Holds version info for the VersionId SOAP object.
29+
self._version_info = {
30+
'service_id': 'aval',
31+
'major': '4',
32+
'intermediate': '0',
33+
'minor': '0'
34+
}
35+
36+
# self.AddressValidationOptions = None
37+
"""@ivar: Holds the AddressValidationOptions WSDL object."""
38+
self.AddressesToValidate = []
39+
"""@ivar: Holds the AddressToValidate WSDL object."""
40+
# Call the parent FedexBaseService class for basic setup work.
41+
super(FedexAddressValidationRequest, self).__init__(
42+
self._config_obj, 'AddressValidationService_v4.wsdl', *args, **kwargs)
43+
44+
def _prepare_wsdl_objects(self):
45+
"""
46+
Create the data structure and get it ready for the WSDL request.
47+
"""
48+
pass
49+
50+
def _assemble_and_send_request(self):
51+
"""
52+
Fires off the Fedex request.
53+
54+
@warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(),
55+
WHICH RESIDES ON FedexBaseService AND IS INHERITED.
56+
"""
57+
58+
# We get an exception like this when specifying an IntegratorId:
59+
# suds.TypeNotFound: Type not found: 'IntegratorId'
60+
# Setting it to None does not seem to appease it.
61+
del self.ClientDetail.IntegratorId
62+
self.logger.debug(self.WebAuthenticationDetail)
63+
self.logger.debug(self.ClientDetail)
64+
self.logger.debug(self.TransactionDetail)
65+
self.logger.debug(self.VersionId)
66+
# Fire off the query.
67+
return self.client.service.addressValidation(
68+
WebAuthenticationDetail=self.WebAuthenticationDetail,
69+
ClientDetail=self.ClientDetail,
70+
TransactionDetail=self.TransactionDetail,
71+
Version=self.VersionId,
72+
InEffectAsOfTimestamp=datetime.now(),
73+
AddressesToValidate=self.AddressesToValidate)
74+
75+
def add_address(self, address_item):
76+
"""
77+
Adds an address to self.AddressesToValidate.
78+
79+
@type address_item: WSDL object, type of AddressToValidate WSDL object.
80+
@keyword address_item: A AddressToValidate, created by
81+
calling create_wsdl_object_of_type('AddressToValidate') on
82+
this FedexAddressValidationRequest object.
83+
See examples/create_shipment.py for more details.
84+
"""
85+
86+
self.AddressesToValidate.append(address_item)

0 commit comments

Comments
 (0)