Skip to content

Commit 71060c8

Browse files
committed
Merge pull request #56 from radlws/suds_jurko
Suds jurko
2 parents 8e380ea + 7443db6 commit 71060c8

14 files changed

+98
-105
lines changed

CHANGES.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Change Log
22
==========
33

4-
TODO: next release
5-
------------------
4+
1.2.0
5+
-----
66

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

1617
1.1.1
1718
-----

examples/address_validation.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,49 +50,45 @@ class can handle up to 100 addresses for validation.
5050

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

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

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

6565
# good to un-comment to see the variables returned by the Fedex reply.
66-
print avs_request.response
67-
#print avs_request.client.last_received()
68-
69-
# See the request printed out.
70-
#print avs_request.client.last_sent()
66+
print(avs_request.response)
7167

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

75-
print "Details for Address", i + 1
76-
print "The validated street is:", avs_request.response.AddressResults[i].EffectiveAddress.StreetLines
77-
print "The validated city is:", avs_request.response.AddressResults[i].EffectiveAddress.City
78-
print "The validated state code is:", avs_request.response.AddressResults[i].EffectiveAddress.StateOrProvinceCode
79-
print "The validated postal code is:", avs_request.response.AddressResults[i].EffectiveAddress.PostalCode
80-
print "The validated country code is:", avs_request.response.AddressResults[i].EffectiveAddress.CountryCode
71+
print("Details for Address", i + 1)
72+
print("The validated street is:", avs_request.response.AddressResults[i].EffectiveAddress.StreetLines)
73+
print("The validated city is:", avs_request.response.AddressResults[i].EffectiveAddress.City)
74+
print("The validated state code is:", avs_request.response.AddressResults[i].EffectiveAddress.StateOrProvinceCode)
75+
print("The validated postal code is:", avs_request.response.AddressResults[i].EffectiveAddress.PostalCode)
76+
print("The validated country code is:", avs_request.response.AddressResults[i].EffectiveAddress.CountryCode)
8177

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

8682
# Getting the optional attributes if available
8783
for j in range(len(avs_request.response.AddressResults[i].Attributes)):
8884
cur_attribute = avs_request.response.AddressResults[i].Attributes[j]
8985
if cur_attribute.Name == "CountrySupported":
90-
print "Supported Country:", cur_attribute.Value == 'true'
86+
print("Supported Country:", cur_attribute.Value == 'true')
9187
if cur_attribute.Name == "SuiteRequiredButMissing":
92-
print "Missing Suite:", cur_attribute.Value == 'true'
88+
print("Missing Suite:", cur_attribute.Value == 'true')
9389
if cur_attribute.Name == "CountrySupported":
94-
print "Invalid Suite:", cur_attribute.Value == 'true'
90+
print("Invalid Suite:", cur_attribute.Value == 'true')
9591
if cur_attribute.Name == "MultipleMatches":
96-
print "Multiple Matches:", cur_attribute.Value == 'true'
92+
print("Multiple Matches:", cur_attribute.Value == 'true')
9793
if cur_attribute.Name == "POBox":
98-
print "Is POBox:", cur_attribute.Value == 'true'
94+
print("Is POBox:", cur_attribute.Value == 'true')

examples/create_freight_shipment.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@
129129

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

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

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

159-
# See the request printed out.
160-
#print shipment.client.last_sent()
161158

162159
# # Get the label image in ASCII format from the reply. Note the list indices
163160
# we're using. You'll need to adjust or iterate through these if your shipment
@@ -173,7 +170,7 @@
173170
"""
174171
# This will be the file we write the label out to.
175172
out_path = 'example_freight_shipment_label.%s' % GENERATE_IMAGE_TYPE.lower()
176-
print "Writing to file", out_path
173+
print("Writing to file", out_path)
177174
out_file = open(out_path, 'wb')
178175
out_file.write(label_binary_data)
179176
out_file.close()
@@ -196,6 +193,6 @@
196193
"""
197194
#import serial
198195
#label_printer = serial.Serial(0)
199-
#print "SELECTED SERIAL PORT: "+ label_printer.portstr
196+
#print("SELECTED SERIAL PORT: "+ label_printer.portstr)
200197
#label_printer.write(label_binary_data)
201198
#label_printer.close()

examples/create_shipment.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,52 +112,48 @@
112112
package1.PhysicalPackaging = 'ENVELOPE'
113113
package1.Weight = package1_weight
114114
# Un-comment this to see the other variables you may set on a package.
115-
#print package1
115+
#print(package1)
116116

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

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

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

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

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

140140
# This will show the reply to your shipment being sent. You can access the
141141
# attributes through the response attribute on the request object. This is
142142
# good to un-comment to see the variables returned by the Fedex reply.
143-
print shipment.response
144-
#print shipment.client.last_received()
145-
146-
# See the request printed out.
147-
#print shipment.client.last_sent()
143+
print(shipment.response)
148144

149145
# Here is the overall end result of the query.
150-
print "HighestSeverity:", shipment.response.HighestSeverity
146+
print("HighestSeverity:", shipment.response.HighestSeverity)
151147

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

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

162158
# Get the label image in ASCII format from the reply. Note the list indices
163159
# we're using. You'll need to adjust or iterate through these if your shipment
@@ -173,7 +169,7 @@
173169
"""
174170
# This will be the file we write the label out to.
175171
out_path = 'example_shipment_label.%s' % GENERATE_IMAGE_TYPE.lower()
176-
print "Writing to file", out_path
172+
print("Writing to file", out_path)
177173
out_file = open(out_path, 'wb')
178174
out_file.write(label_binary_data)
179175
out_file.close()
@@ -196,7 +192,7 @@
196192
"""
197193
#import serial
198194
#label_printer = serial.Serial(0)
199-
#print "SELECTED SERIAL PORT: "+ label_printer.portstr
195+
#print("SELECTED SERIAL PORT: "+ label_printer.portstr)
200196
#label_printer.write(label_binary_data)
201197
#label_printer.close()
202198

examples/delete_shipment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@
3030
del_request.send_request()
3131

3232
# See the response printed out.
33-
print del_request.response
33+
print(del_request.response)

examples/freight_rate_request.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,34 +99,33 @@
9999

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

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

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

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

119117
# Here is the overall end result of the query.
120-
print "HighestSeverity:", rate_request.response.HighestSeverity
118+
print("HighestSeverity:", rate_request.response.HighestSeverity)
121119

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

129127
for rate_detail in service.RatedShipmentDetails:
130-
print "%s: Net FedEx Charge %s %s" % (service.ServiceType, rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Currency,
131-
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Amount)
128+
print("{}: Net FedEx Charge {} {}".format(service.ServiceType,
129+
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Currency,
130+
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Amount))
132131

examples/postal_inquiry.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,17 @@
1717

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

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

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

3232
# See the response printed out.
33-
print inquiry.response
34-
#print inquiry.client.last_received()
35-
36-
# See the response printed out.
37-
#print inquiry.client.last_sent()
38-
33+
print(inquiry.response)

examples/rate_request.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,45 +74,41 @@
7474
# The result will be found in RatedPackageDetail, with specified GroupNumber.
7575
package1.GroupPackageCount = 1
7676
# Un-comment this to see the other variables you may set on a package.
77-
#print package1
77+
#print(package1)
7878

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

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

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

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

9595
# This will show the reply to your rate_request being sent. You can access the
9696
# attributes through the response attribute on the request object. This is
9797
# good to un-comment to see the variables returned by the FedEx reply.
98-
#print rate_request.response
99-
#print rate_request.client.last_received()
100-
101-
# See the response printed out.
102-
#print rate_request.client.last_sent()
103-
98+
#print(rate_request.response)
10499

105100
# Here is the overall end result of the query.
106-
print "HighestSeverity:", rate_request.response.HighestSeverity
101+
print("HighestSeverity:", rate_request.response.HighestSeverity)
107102

108103
# RateReplyDetails can contain rates for multiple ServiceTypes if ServiceType was set to None
109104
for service in rate_request.response.RateReplyDetails:
110105
for detail in service.RatedShipmentDetails:
111106
for surcharge in detail.ShipmentRateDetail.Surcharges:
112107
if surcharge.SurchargeType == 'OUT_OF_DELIVERY_AREA':
113-
print "%s: ODA rate_request charge %s" % (service.ServiceType, surcharge.Amount.Amount)
108+
print("%s: ODA rate_request charge %s" % (service.ServiceType, surcharge.Amount.Amount))
114109

115110
for rate_detail in service.RatedShipmentDetails:
116-
print "%s: Net FedEx Charge %s %s" % (service.ServiceType, rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Currency,
117-
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Amount)
111+
print("%s: Net FedEx Charge %s %s" % (service.ServiceType,
112+
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Currency,
113+
rate_detail.ShipmentRateDetail.TotalNetFedExCharge.Amount))
118114

0 commit comments

Comments
 (0)