Skip to content

Commit

Permalink
Merge pull request #56 from radlws/suds_jurko
Browse files Browse the repository at this point in the history
Suds jurko
  • Loading branch information
gtaylor committed Dec 17, 2015
2 parents 8e380ea + 7443db6 commit 71060c8
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 105 deletions.
5 changes: 3 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Change Log
==========

TODO: next release
------------------
1.2.0
-----

* Bump ShipService WSDL to v17 for create and delete shipment. (radlws)
* Bump AddressValidation WSDL to v4. (radlws)
Expand All @@ -12,6 +12,7 @@ TODO: next release
* Refactoring and updates to examples. (radlws)
* Added test classes. (radlws)
* Remove old and unused WSDLs. (radlws)
* Change dependency to suds-jurko to include python 3 support. (radlws)

1.1.1
-----
Expand Down
38 changes: 17 additions & 21 deletions examples/address_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,49 +50,45 @@ class can handle up to 100 addresses for validation.

# If you'd like to see some documentation on the ship service WSDL, un-comment
# this line. (Spammy).
#print avs_request.client
#print(avs_request.client)

# Un-comment this to see your complete, ready-to-send request as it stands
# before it is actually sent. This is useful for seeing what values you can
# change.
#print avs_request.AddressesToValidate
#print avs_request.ClientDetail
#print avs_request.TransactionDetail
#print(avs_request.AddressesToValidate)
#print(avs_request.ClientDetail)
#print(avs_request.TransactionDetail)

# Fires off the request, sets the 'response' attribute on the object.
avs_request.send_request()

# good to un-comment to see the variables returned by the Fedex reply.
print avs_request.response
#print avs_request.client.last_received()

# See the request printed out.
#print avs_request.client.last_sent()
print(avs_request.response)

# Overall end result of the query
for i in range(len(avs_request.response.AddressResults)):

print "Details for Address", i + 1
print "The validated street is:", avs_request.response.AddressResults[i].EffectiveAddress.StreetLines
print "The validated city is:", avs_request.response.AddressResults[i].EffectiveAddress.City
print "The validated state code is:", avs_request.response.AddressResults[i].EffectiveAddress.StateOrProvinceCode
print "The validated postal code is:", avs_request.response.AddressResults[i].EffectiveAddress.PostalCode
print "The validated country code is:", avs_request.response.AddressResults[i].EffectiveAddress.CountryCode
print("Details for Address", i + 1)
print("The validated street is:", avs_request.response.AddressResults[i].EffectiveAddress.StreetLines)
print("The validated city is:", avs_request.response.AddressResults[i].EffectiveAddress.City)
print("The validated state code is:", avs_request.response.AddressResults[i].EffectiveAddress.StateOrProvinceCode)
print("The validated postal code is:", avs_request.response.AddressResults[i].EffectiveAddress.PostalCode)
print("The validated country code is:", avs_request.response.AddressResults[i].EffectiveAddress.CountryCode)

# Can be used to determine the address classification to figure out if Residential fee should apply.
# MIXED, RESIDENTIAL, UNKNOWN, BUSINESS
print "The validated address is residential:", avs_request.response.AddressResults[i].Classification != 'BUSINESS'
print("The validated address is residential:", avs_request.response.AddressResults[i].Classification != 'BUSINESS')

# Getting the optional attributes if available
for j in range(len(avs_request.response.AddressResults[i].Attributes)):
cur_attribute = avs_request.response.AddressResults[i].Attributes[j]
if cur_attribute.Name == "CountrySupported":
print "Supported Country:", cur_attribute.Value == 'true'
print("Supported Country:", cur_attribute.Value == 'true')
if cur_attribute.Name == "SuiteRequiredButMissing":
print "Missing Suite:", cur_attribute.Value == 'true'
print("Missing Suite:", cur_attribute.Value == 'true')
if cur_attribute.Name == "CountrySupported":
print "Invalid Suite:", cur_attribute.Value == 'true'
print("Invalid Suite:", cur_attribute.Value == 'true')
if cur_attribute.Name == "MultipleMatches":
print "Multiple Matches:", cur_attribute.Value == 'true'
print("Multiple Matches:", cur_attribute.Value == 'true')
if cur_attribute.Name == "POBox":
print "Is POBox:", cur_attribute.Value == 'true'
print("Is POBox:", cur_attribute.Value == 'true')
19 changes: 8 additions & 11 deletions examples/create_freight_shipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@

# If you'd like to see some documentation on the ship service WSDL, un-comment
# this line. (Spammy).
#print shipment.client
#print(shipment.client)

# Un-comment this to see your complete, ready-to-send request as it stands
# before it is actually sent. This is useful for seeing what values you can
# change.
#print shipment.RequestedShipment
#print(shipment.RequestedShipment)

# If you want to make sure that all of your entered details are valid, you
# can call this and parse it just like you would via send_request(). If
Expand All @@ -147,17 +147,14 @@
# This will show the reply to your shipment being sent. You can access the
# attributes through the response attribute on the request object. This is
# good to un-comment to see the variables returned by the Fedex reply.
print shipment.response
#print shipment.client.last_received()
print(shipment.response)
# Here is the overall end result of the query.
# print "HighestSeverity:", shipment.response.HighestSeverity
# print("HighestSeverity:", shipment.response.HighestSeverity)
# # Getting the tracking number from the new shipment.
# print "Tracking #:", shipment.response.CompletedShipmentDetail.CompletedPackageDetails[0].TrackingIds[0].TrackingNumber
# print("Tracking #:", shipment.response.CompletedShipmentDetail.CompletedPackageDetails[0].TrackingIds[0].TrackingNumber)
# # Net shipping costs.
# print "Net Shipping Cost (US$):", shipment.response.CompletedShipmentDetail.CompletedPackageDetails[0].PackageRating.PackageRateDetails[0].NetCharge.Amount
# print("Net Shipping Cost (US$):", shipment.response.CompletedShipmentDetail.CompletedPackageDetails[0].PackageRating.PackageRateDetails[0].NetCharge.Amount)

# See the request printed out.
#print shipment.client.last_sent()

# # Get the label image in ASCII format from the reply. Note the list indices
# we're using. You'll need to adjust or iterate through these if your shipment
Expand All @@ -173,7 +170,7 @@
"""
# This will be the file we write the label out to.
out_path = 'example_freight_shipment_label.%s' % GENERATE_IMAGE_TYPE.lower()
print "Writing to file", out_path
print("Writing to file", out_path)
out_file = open(out_path, 'wb')
out_file.write(label_binary_data)
out_file.close()
Expand All @@ -196,6 +193,6 @@
"""
#import serial
#label_printer = serial.Serial(0)
#print "SELECTED SERIAL PORT: "+ label_printer.portstr
#print("SELECTED SERIAL PORT: "+ label_printer.portstr)
#label_printer.write(label_binary_data)
#label_printer.close()
30 changes: 13 additions & 17 deletions examples/create_shipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,52 +112,48 @@
package1.PhysicalPackaging = 'ENVELOPE'
package1.Weight = package1_weight
# Un-comment this to see the other variables you may set on a package.
#print package1
#print(package1)

# This adds the RequestedPackageLineItem WSDL object to the shipment. It
# increments the package count and total weight of the shipment for you.
shipment.add_package(package1)

# If you'd like to see some documentation on the ship service WSDL, un-comment
# this line. (Spammy).
# print shipment.client
#print(shipment.client)

# Un-comment this to see your complete, ready-to-send request as it stands
# before it is actually sent. This is useful for seeing what values you can
# change.
#print shipment.RequestedShipment
#print shipment.ClientDetail
#print shipment.TransactionDetail
#print(shipment.RequestedShipment)
#print(shipment.ClientDetail)
#print(shipment.TransactionDetail)

# If you want to make sure that all of your entered details are valid, you
# can call this and parse it just like you would via send_request(). If
# shipment.response.HighestSeverity == "SUCCESS", your shipment is valid.
#print shipment.send_validation_request()
#print(shipment.send_validation_request())

# Fires off the request, sets the 'response' attribute on the object.
shipment.send_request()

# This will show the reply to your shipment being sent. You can access the
# attributes through the response attribute on the request object. This is
# good to un-comment to see the variables returned by the Fedex reply.
print shipment.response
#print shipment.client.last_received()

# See the request printed out.
#print shipment.client.last_sent()
print(shipment.response)

# Here is the overall end result of the query.
print "HighestSeverity:", shipment.response.HighestSeverity
print("HighestSeverity:", shipment.response.HighestSeverity)

# Getting the tracking number from the new shipment.
print "Tracking #:", shipment.response.CompletedShipmentDetail.CompletedPackageDetails[0].TrackingIds[0].TrackingNumber
print("Tracking #:", shipment.response.CompletedShipmentDetail.CompletedPackageDetails[0].TrackingIds[0].TrackingNumber)

# Net shipping costs. Only show if available. Sometimes sandbox will not include this in the response.
CompletedPackageDetails = shipment.response.CompletedShipmentDetail.CompletedPackageDetails[0]
if hasattr(CompletedPackageDetails, 'PackageRating'):
print "Net Shipping Cost (US$):", CompletedPackageDetails.PackageRating.PackageRateDetails[0].NetCharge.Amount
print("Net Shipping Cost (US$):", CompletedPackageDetails.PackageRating.PackageRateDetails[0].NetCharge.Amount)
else:
print 'WARNING: Unable to get rate.'
print('WARNING: Unable to get rate.')

# Get the label image in ASCII format from the reply. Note the list indices
# we're using. You'll need to adjust or iterate through these if your shipment
Expand All @@ -173,7 +169,7 @@
"""
# This will be the file we write the label out to.
out_path = 'example_shipment_label.%s' % GENERATE_IMAGE_TYPE.lower()
print "Writing to file", out_path
print("Writing to file", out_path)
out_file = open(out_path, 'wb')
out_file.write(label_binary_data)
out_file.close()
Expand All @@ -196,7 +192,7 @@
"""
#import serial
#label_printer = serial.Serial(0)
#print "SELECTED SERIAL PORT: "+ label_printer.portstr
#print("SELECTED SERIAL PORT: "+ label_printer.portstr)
#label_printer.write(label_binary_data)
#label_printer.close()

2 changes: 1 addition & 1 deletion examples/delete_shipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
del_request.send_request()

# See the response printed out.
print del_request.response
print(del_request.response)
17 changes: 8 additions & 9 deletions examples/freight_rate_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,34 +99,33 @@

# If you'd like to see some documentation on the ship service WSDL, un-comment
# this line. (Spammy).
#print rate_request.client
#print(rate_request.client)

# Un-comment this to see your complete, ready-to-send request as it stands
# before it is actually sent. This is useful for seeing what values you can
# change.
#print rate_request.RequestedShipment
#print(rate_request.RequestedShipment)

# Fires off the request, sets the 'response' attribute on the object.
rate_request.send_request()
#print rate_request.client.last_received()

# This will show the reply to your rate_request being sent. You can access the
# attributes through the response attribute on the request object. This is
# good to un-comment to see the variables returned by the FedEx reply.
print rate_request.response
#print rate_request.client.last_sent()
print(rate_request.response)

# Here is the overall end result of the query.
print "HighestSeverity:", rate_request.response.HighestSeverity
print("HighestSeverity:", rate_request.response.HighestSeverity)

# RateReplyDetails can contain rates for multiple ServiceTypes if ServiceType was set to None
for service in rate_request.response.RateReplyDetails:
for detail in service.RatedShipmentDetails:
for surcharge in detail.ShipmentRateDetail.Surcharges:
if surcharge.SurchargeType == 'OUT_OF_DELIVERY_AREA':
print "%s: ODA rate_request charge %s" % (service.ServiceType, surcharge.Amount.Amount)
print("%s: ODA rate_request charge {}".format(service.ServiceType, surcharge.Amount.Amount))

for rate_detail in service.RatedShipmentDetails:
print "%s: Net FedEx Charge %s %s" % (service.ServiceType, rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Currency,
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Amount)
print("{}: Net FedEx Charge {} {}".format(service.ServiceType,
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Currency,
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Amount))

15 changes: 5 additions & 10 deletions examples/postal_inquiry.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,17 @@

# If you'd like to see some documentation on the ship service WSDL, un-comment
# this line. (Spammy).
#print inquiry.client
#print(inquiry.client)

# Un-comment this to see your complete, ready-to-send request as it stands
# before it is actually sent. This is useful for seeing what values you can
# change.
#print inquiry.CarrierCode
#print inquiry.ClientDetail
#print inquiry.TransactionDetail
#print(inquiry.CarrierCode)
#print(inquiry.ClientDetail)
#print(inquiry.TransactionDetail)

# Fires off the request, sets the 'response' attribute on the object.
inquiry.send_request()

# See the response printed out.
print inquiry.response
#print inquiry.client.last_received()

# See the response printed out.
#print inquiry.client.last_sent()

print(inquiry.response)
22 changes: 9 additions & 13 deletions examples/rate_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,45 +74,41 @@
# The result will be found in RatedPackageDetail, with specified GroupNumber.
package1.GroupPackageCount = 1
# Un-comment this to see the other variables you may set on a package.
#print package1
#print(package1)

# This adds the RequestedPackageLineItem WSDL object to the rate_request. It
# increments the package count and total weight of the rate_request for you.
rate_request.add_package(package1)

# If you'd like to see some documentation on the ship service WSDL, un-comment
# this line. (Spammy).
#print rate_request.client
#print(rate_request.client)

# Un-comment this to see your complete, ready-to-send request as it stands
# before it is actually sent. This is useful for seeing what values you can
# change.
#print rate_request.RequestedShipment
#print(rate_request.RequestedShipment)

# Fires off the request, sets the 'response' attribute on the object.
rate_request.send_request()

# This will show the reply to your rate_request being sent. You can access the
# attributes through the response attribute on the request object. This is
# good to un-comment to see the variables returned by the FedEx reply.
#print rate_request.response
#print rate_request.client.last_received()

# See the response printed out.
#print rate_request.client.last_sent()

#print(rate_request.response)

# Here is the overall end result of the query.
print "HighestSeverity:", rate_request.response.HighestSeverity
print("HighestSeverity:", rate_request.response.HighestSeverity)

# RateReplyDetails can contain rates for multiple ServiceTypes if ServiceType was set to None
for service in rate_request.response.RateReplyDetails:
for detail in service.RatedShipmentDetails:
for surcharge in detail.ShipmentRateDetail.Surcharges:
if surcharge.SurchargeType == 'OUT_OF_DELIVERY_AREA':
print "%s: ODA rate_request charge %s" % (service.ServiceType, surcharge.Amount.Amount)
print("%s: ODA rate_request charge %s" % (service.ServiceType, surcharge.Amount.Amount))

for rate_detail in service.RatedShipmentDetails:
print "%s: Net FedEx Charge %s %s" % (service.ServiceType, rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Currency,
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Amount)
print("%s: Net FedEx Charge %s %s" % (service.ServiceType,
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Currency,
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Amount))

Loading

0 comments on commit 71060c8

Please sign in to comment.