Skip to content

Commit 5b4318a

Browse files
Rad WojcikRad Wojcik
authored andcommitted
add suds-jurko support, still compatible with suds
1 parent 8e380ea commit 5b4318a

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

fedex/base_service.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,20 @@
1212

1313
import suds
1414
from suds.client import Client
15+
from suds.plugin import MessagePlugin
1516

1617

18+
class GeneralPlugin(MessagePlugin):
19+
20+
def marshalled(self, context):
21+
context.envelope = context.envelope.prune()
22+
23+
def sending(self, context):
24+
logging.info("FedEx Request {}".format(context.envelope))
25+
26+
def received(self, context):
27+
logging.info("FedEx Response {}".format(context.reply))
28+
1729
class FedexBaseServiceException(Exception):
1830
"""
1931
Exception: Serves as the base exception that other service-related
@@ -101,7 +113,7 @@ def __init__(self, config_obj, wsdl_name, *args, **kwargs):
101113
self.logger.info("Using production server.")
102114
self.wsdl_path = os.path.join(config_obj.wsdl_path, wsdl_name)
103115

104-
self.client = Client('file:///%s' % self.wsdl_path.lstrip('/'), faults=True)
116+
self.client = Client('file:///%s' % self.wsdl_path.lstrip('/'), plugins=[GeneralPlugin()])
105117
#self.client.options.cache.clear() # Clear the cache, then re-init client when changing wsdl file.
106118

107119
self.VersionId = None

fedex/services/track_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,5 @@ def _assemble_and_send_request(self):
108108
TransactionDetail=self.TransactionDetail,
109109
Version=self.VersionId,
110110
SelectionDetails=self.SelectionDetails,
111-
TrackRequestProcessingOptionType=self.TrackRequestProcessingOptionType)
111+
ProcessingOptions=self.TrackRequestProcessingOptionType)
112112

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
license='BSD',
3232
classifiers=CLASSIFIERS,
3333
keywords=KEYWORDS,
34-
requires=['suds'],
35-
install_requires=['suds'],
34+
requires=['suds-jurko'],
35+
install_requires=['suds-jurko'],
3636
)

tests/test_ship_service.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def test_create_delete_shipment(self):
5555
shipment.RequestedShipment.LabelSpecification.LabelStockType = 'PAPER_7X4.75'
5656
shipment.RequestedShipment.LabelSpecification.LabelPrintingOrientation = 'BOTTOM_EDGE_OF_TEXT_FIRST'
5757

58+
# Use order if setting multiple labels or delete
5859
del shipment.RequestedShipment.LabelSpecification.LabelOrder
5960

6061
package1_weight = shipment.create_wsdl_object_of_type('Weight')

0 commit comments

Comments
 (0)