-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
406 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from suds.client import Client | ||
|
||
""" | ||
required fields for basic client response : | ||
1.url (different for each service) | ||
development and production environment urls are different.please check with developers guide after creating developer account | ||
2.username - provided by purolator | ||
3.password - provided by purolator | ||
4. Language- currently english and french are supported | ||
5.UserToken - provided with developer account. production account does not need one | ||
6.Version - latest version of particular service. Provided in each pdf of each service's developer guide | ||
""" | ||
|
||
|
||
url = "https://devwebservices.purolator.com/EWS/V1/ShippingDocuments/ShippingDocumentsService.wsdl" | ||
client = Client(url,username='myusername',password='mypassword') | ||
Language = client.factory.create('ns0:Language') | ||
RequestContext = client.factory.create('ns0:RequestContext') | ||
RequestContext.Version = '1.3' | ||
RequestContext.GroupID = 'xxx' | ||
RequestContext.RequestReference = 'Rating Example' | ||
RequestContext.Language = Language.en | ||
RequestContext.UserToken = 'myusertoken' | ||
client.set_options(soapheaders=RequestContext) | ||
print "first client response",client | ||
####################################################################################################### | ||
# method1 :getdocument | ||
ArrayOfDocumentCriteria = client.factory.create('ns0:ArrayOfDocumentCriteria') | ||
DocumentCriteria = client.factory.create('ns0:DocumentCriteria') | ||
DocumentCriteria.PIN.Value = 329015010179 #generic pin got after performing create shipment | ||
DocumentCriteria.DocumentTypes.DocumentType = "DomesticBillOfLading" | ||
ArrayOfDocumentCriteria.DocumentCriteria = DocumentCriteria | ||
response1 = client.service.GetDocuments('PDF',False,ArrayOfDocumentCriteria) | ||
print "GetDocuments_response",response1 | ||
|
||
################################################################################## | ||
#method 2 :GetShipmentManifestDocument | ||
ArrayOfShipmentManifestDocumentCriteria = client.factory.create('ns0:ArrayOfShipmentManifestDocumentCriteria') | ||
ShipmentManifestDocumentCriteria = client.factory.create('ns0:ShipmentManifestDocumentCriteria') | ||
ShipmentManifestDocumentCriteria.ManifestDate = '2010-03-15' | ||
ArrayOfShipmentManifestDocumentCriteria.ShipmentManifestDocumentCriteria = ShipmentManifestDocumentCriteria | ||
|
||
response2 = client.service.GetShipmentManifestDocument(ArrayOfShipmentManifestDocumentCriteria) | ||
print "GetShipmentManifestDocument_response2>>>>>>>>>>>>>>>",response2 | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
|
||
from suds.client import Client | ||
|
||
""" | ||
required fields for basic client response : | ||
1.url (different for each service) | ||
development and production environment urls are different.please check with developers guide after creating developer account | ||
2.username - provided by purolator | ||
3.password - provided by purolator | ||
4. Language- currently english and french are supported | ||
5.UserToken - provided with developer account. production account does not need one | ||
6.Version - latest version of particular service. Provided in each pdf of each service's developer guide | ||
""" | ||
|
||
|
||
url = "https://devwebservices.purolator.com/EWS/V1/Locator/LocatorService.wsdl" | ||
client = Client(url,username='yourusername',password='yourpassword') | ||
Language = client.factory.create('ns0:Language') | ||
RequestContext = client.factory.create('ns0:RequestContext') | ||
RequestContext.Version = '1.0' | ||
RequestContext.GroupID = 'xxx' | ||
RequestContext.RequestReference = 'Rating Example' | ||
RequestContext.Language = Language.en | ||
RequestContext.UserToken = 'YOURUserToken' | ||
client.set_options(soapheaders=RequestContext) | ||
print "client response-->",client | ||
########################################################################## | ||
# GetLocationsByAddress(ns0:Address Address, ns0:SearchOptions SearchOptions, ns0:LocationTypes LocationTypes, ns0:HoursOfOperation HoursOfOperation, ns0:DaysOfOperation DaysOfOperation) | ||
# GetLocationsByCity(xs:string CountryCode, xs:string CityName, xs:string ProvinceStateCode, ns0:SearchOptions SearchOptions, ns0:LocationTypes LocationTypes, ns0:HoursOfOperation HoursOfOperation, ns0:DaysOfOperation DaysOfOperation) | ||
# GetLocationsByCoordinates(ns0:Coordinates Coordinates, ns0:SearchOptions SearchOptions, ns0:LocationTypes LocationTypes, ns0:HoursOfOperation HoursOfOperation, ns0:DaysOfOperation DaysOfOperation) | ||
# GetLocationsByPointOfInterest(xs:string PointOfInterest, ns0:SearchOptions SearchOptions, ns0:LocationTypes LocationTypes, ns0:HoursOfOperation HoursOfOperation, ns0:DaysOfOperation DaysOfOperation) | ||
# GetLocationsByPostalCode(xs:string PostalCode, ns0:SearchOptions SearchOptions, ns0:LocationTypes LocationTypes, ns0:HoursOfOperation HoursOfOperation, ns0:DaysOfOperation DaysOfOperation) | ||
|
||
|
||
#service 1 : GetLocationsByAddress | ||
|
||
GetLocationsByAddressRequestContainer = client.factory.create('ns0:GetLocationsByAddressRequestContainer') | ||
|
||
Address = client.factory.create('ns0:Address') | ||
SearchOptions = client.factory.create('ns0:SearchOptions') | ||
LocationTypes = client.factory.create('ns0:LocationTypes') | ||
HoursOfOperation = client.factory.create('ns0:HoursOfOperation') | ||
DaysOfOperation = client.factory.create('ns0:DaysOfOperation') | ||
|
||
|
||
|
||
print "MyAddress>>>>>>>",GetLocationsByAddressRequestContainer | ||
Address.AddressLine1 = '120 Dundas St E' | ||
Address.AddressLine2 = 'Calgary, AB' | ||
Address.AddressLine3 = 'T2P3N9' | ||
|
||
SearchOptions.RadialDistanceInKM = '100' | ||
# GetLocationsByAddressRequestContainer.SearchOptions.HoldForPickup = 'Edmonton' | ||
SearchOptions.DangerousGoods = 'true' | ||
# GetLocationsByAddressRequestContainer.SearchOptions.Kiosk = 'Edmonton' | ||
SearchOptions.StreetAccess = 'true' | ||
SearchOptions.WheelChairAccess = 'true' | ||
SearchOptions.MaxNumberOfLocations = '10' | ||
LocationTypes.LocationType = 'ShippingCentre' | ||
HoursOfOperation.OpenTime = '09:00:00' | ||
HoursOfOperation.CloseTime = '17:00:00' | ||
HoursOfOperation.CurrentlyOpen = True | ||
HoursOfOperation.GMTOffset = '17:00:00' | ||
DaysOfOperation.DaysOfWeek =['Monday'] | ||
response = client.service.GetLocationsByAddress(Address, SearchOptions, LocationTypes, HoursOfOperation, DaysOfOperation) | ||
print "GetLocationsByAddress_response",response | ||
################################################################################################ | ||
#service 2 GetLocationsByCity | ||
CountryCode = 'ON' | ||
CityName = 'Mississuaga' | ||
ProvinceStateCode = 'CA' | ||
response2= client.service.GetLocationsByCity(CountryCode,CityName,ProvinceStateCode,SearchOptions,LocationTypes,HoursOfOperation,DaysOfOperation) | ||
print "GetLocationsByCity_response",response2 | ||
############################################################################################### | ||
#service 3 GetLocationsByCoordinates | ||
Coordinates = client.factory.create('ns0:Coordinates') | ||
Coordinates.Longitude = '43.3310093000' | ||
Coordinates.Latitude = '79.8195676000' | ||
response3=client.service.GetLocationsByCoordinates(Coordinates,SearchOptions,LocationTypes,HoursOfOperation,DaysOfOperation) | ||
print "GetLocationsByCoordinates_response",response3 | ||
################################################################################### | ||
#method 4 GetLocationsByPointOfInterest | ||
PointOfInterest ="FairView" | ||
response4=client.service.GetLocationsByPointOfInterest(PointOfInterest,SearchOptions,LocationTypes,HoursOfOperation,DaysOfOperation) | ||
print "GetLocationsByPointOfInterest_response",response4 | ||
####################################################################### | ||
# method 5 GetLocationsByPostalCode | ||
PostalCode = 'L5N3B5' | ||
response5=client.service.GetLocationsByPostalCode(PostalCode,SearchOptions,LocationTypes,HoursOfOperation,DaysOfOperation) | ||
print "GetLocationsByPostalCode_response",response5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
from suds.client import Client | ||
|
||
""" | ||
required fields for basic client response : | ||
1.url (different for each service) | ||
development and production environment urls are different.please check with developers guide after creating developer account | ||
2.username - provided by purolator | ||
3.password - provided by purolator | ||
4. Language- currently english and french are supported | ||
5.UserToken - provided with developer account. production account does not need one | ||
6.Version - latest version of particular service. Provided in each pdf of each service's developer guide | ||
""" | ||
|
||
url = "https://devwebservices.purolator.com/EWS/V1/PickUp/PickUpService.wsdl" | ||
client = Client(url,username='yourusername',password='yourpassword') | ||
Language = client.factory.create('ns0:Language') | ||
RequestContext = client.factory.create('ns0:RequestContext') | ||
RequestContext.Version = '1.2' | ||
RequestContext.GroupID = 'xxx' | ||
RequestContext.RequestReference = 'Pickup Examples' | ||
RequestContext.Language = Language.en | ||
RequestContext.UserToken = 'YourUserToken' | ||
print"RequestContext",RequestContext | ||
client.set_options(soapheaders=RequestContext) | ||
print "first client response",client | ||
########################################################################## | ||
PickUpHistorySearchCriteria = client.factory.create('ns0:PickUpHistorySearchCriteria') | ||
|
||
PickUpHistorySearchCriteria.AccountNumber = "yourAccountNumber" | ||
PickUpHistorySearchCriteria.ConfirmationNumber = "YourConfirmationNumber" | ||
PickUpHistorySearchCriteria.FromDate = "2010-03-20" | ||
PickUpHistorySearchCriteria.MaxNumOfRecords = 10 | ||
PickUpHistorySearchCriteria.ToDate = "2010-03-30" | ||
|
||
response1 = client.service.GetPickUpHistory(PickUpHistorySearchCriteria) | ||
print "GetPickUpHistory_response>>",response1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from suds.client import Client | ||
|
||
""" | ||
required fields for basic client response : | ||
1.url (different for each service) | ||
development and production environment urls are different.please check with developers guide after creating developer account | ||
2.username - provided by purolator | ||
3.password - provided by purolator | ||
4. Language- currently english and french are supported | ||
5.UserToken - provided with developer account. production account does not need one | ||
6.Version - latest version of particular service. Provided in each pdf of each service's developer guide | ||
""" | ||
|
||
url = "https://devwebservices.purolator.com/EWS/V1/Tracking/TrackingService.wsdl" | ||
client = Client(url,username='myusername',password='mypassword') | ||
Language = client.factory.create('ns0:Language') | ||
RequestContext = client.factory.create('ns0:RequestContext') | ||
RequestContext.Version = '1.2' | ||
RequestContext.GroupID = 'xxx' | ||
RequestContext.RequestReference = 'Tracking service' | ||
RequestContext.Language = Language.en | ||
RequestContext.UserToken = 'myusertoken' | ||
client.set_options(soapheaders=RequestContext) | ||
print "first client response",client | ||
###################################################################################################### | ||
# GetDeliveryDetails(ns0:PIN PIN) | ||
# TrackPackagesByReference(ns0:TrackPackageByReferenceSearchCriteria TrackPackageByReferenceSearchCriteria) | ||
|
||
PIN = client.factory.create('ns0:PIN') | ||
PIN.Value = '329014521622' | ||
|
||
GetDeliveryDetails_response = client.service.GetDeliveryDetails(PIN) | ||
print ">>>>>>>>GetDeliveryDetails_response>>>>>>>>",GetDeliveryDetails_response | ||
|
||
####################################################################################### | ||
#dummy data | ||
TrackPackageByReferenceSearchCriteria = client.factory.create('ns0:TrackPackageByReferenceSearchCriteria') | ||
TrackPackageByReferenceSearchCriteria.Reference = "RMA125" | ||
TrackPackageByReferenceSearchCriteria.BillingAccountNumber = 'BILLING_ACCOUNT' | ||
TrackPackageByReferenceSearchCriteria.ShipmentFromDate = "2009-04-22" | ||
TrackPackageByReferenceSearchCriteria.ShipmentToDate = "2009-04-22" | ||
|
||
# TrackPackageByReferenceSearchCriteria = MyTrackPackageByReferenceSearchCriteria | ||
response = client.service.TrackPackagesByReference(TrackPackageByReferenceSearchCriteria) | ||
print "TrackPackageByReferenceSearchCriteria_response",response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
from suds.client import Client | ||
|
||
""" | ||
required fields for basic client response : | ||
1.url (different for each service) | ||
development and production environment urls are different.please check with developers guide after creating developer account | ||
2.username - provided by purolator | ||
3.password - provided by purolator | ||
4. Language- currently english and french are supported | ||
5.UserToken - provided with developer account. production account does not need one | ||
6.Version - latest version of particular service. Provided in each pdf of each service's developer guide | ||
""" | ||
|
||
url = "https://devwebservices.purolator.com/ews/v1/Shipping/ShippingService.wsdl" | ||
client = Client(url,username='myusername',password='mypassword') | ||
Language = client.factory.create('ns0:Language') | ||
RequestContext = client.factory.create('ns0:RequestContext') | ||
RequestContext.Version = '1.5' | ||
RequestContext.GroupID = 'xxx' | ||
RequestContext.RequestReference = 'Create Shipment Example' | ||
RequestContext.Language = Language.en | ||
RequestContext.UserToken = 'myusertoken' | ||
client.set_options(soapheaders=RequestContext) | ||
print "thats client-->",client | ||
|
||
################################################################################ | ||
#create basic shipment | ||
#1 piece shipment, 10lbs, Purolator Express Service on a Thermal 4x6 Label | ||
#CreateShipment(ns0:Shipment Shipment, ns0:PrinterType PrinterType) | ||
MyShipment = client.factory.create('ns0:Shipment') | ||
CreateShipmentRequestContainer = client.factory.create('ns0:CreateShipmentRequestContainer') | ||
MyShipment.SenderInformation.Address.Name = 'Manish Shinde' | ||
# OriginAddress.Company = None | ||
# OriginAddress.Department = None | ||
MyShipment.SenderInformation.Address.StreetNumber = 1234 | ||
MyShipment.SenderInformation.Address.StreetName = 'Main Street' | ||
MyShipment.SenderInformation.Address.City = 'Mississauga' | ||
MyShipment.SenderInformation.Address.Province = 'ON' | ||
MyShipment.SenderInformation.Address.Country = 'CA' | ||
MyShipment.SenderInformation.Address.PostalCode = 'L4W5M8' | ||
PhoneNumber = client.factory.create('ns0:PhoneNumber') | ||
MyShipment.SenderInformation.Address.PhoneNumber.CountryCode = '1' | ||
MyShipment.SenderInformation.Address.PhoneNumber.AreaCode = '905' | ||
MyShipment.SenderInformation.Address.PhoneNumber.Phone = '5555555' | ||
MyShipment.SenderInformation.Address.PhoneNumber.Extension = '5555555' | ||
|
||
ReceiverInformation = client.factory.create('ns0:ReceiverInformation') | ||
MyShipment.ReceiverInformation.Address.Name = 'John Doe' | ||
MyShipment.ReceiverInformation.Address.StreetNumber = 1234 | ||
MyShipment.ReceiverInformation.Address.StreetName = 'Douglas Road' | ||
MyShipment.ReceiverInformation.Address.City = 'Burnaby' | ||
MyShipment.ReceiverInformation.Address.Province = 'BC' | ||
MyShipment.ReceiverInformation.Address.Country = 'CA' | ||
MyShipment.ReceiverInformation.Address.PostalCode = 'V5C1A1' | ||
|
||
MyShipment.ReceiverInformation.Address.PhoneNumber.CountryCode = '1' | ||
MyShipment.ReceiverInformation.Address.PhoneNumber.AreaCode = '604' | ||
MyShipment.ReceiverInformation.Address.PhoneNumber.Phone = '2982181' | ||
MyShipment.ReceiverInformation.Address.PhoneNumber.Extension = '2982181' | ||
|
||
MyShipment.PackageInformation.ServiceID = 'PurolatorExpress' | ||
MyShipment.PackageInformation.Description = 'PurolatorExpress detail' | ||
MyShipment.PackageInformation.TotalPieces = '1' | ||
|
||
MyShipment.PackageInformation.TotalWeight.Value = 10 | ||
MyShipment.PackageInformation.TotalWeight.WeightUnit.value = 'lb' | ||
|
||
MyShipment.PaymentInformation.PaymentType.value = "Sender" | ||
MyShipment.PaymentInformation.RegisteredAccountNumber = #yourRegisteredAccountNumber | ||
MyShipment.PaymentInformation.BillingAccountNumber = #yourBillingAccountNumber | ||
MyShipment.ShipmentDate = '2017-12-05' | ||
|
||
# Populate the Pickup Information | ||
PickupInformation = client.factory.create('ns0:PickupInformation') | ||
PickupInformation.PickupType.value = "DropOff" | ||
MyShipment.PickupInformation = PickupInformation | ||
CreateShipmentRequestContainer.Shipment = MyShipment | ||
MyPrinterType = client.factory.create('ns0:PrinterType') | ||
MyPrinterType.Thermal = 'Thermal' | ||
CreateShipmentRequestContainer.PrinterType = MyPrinterType | ||
|
||
response = client.service.CreateShipment(CreateShipmentRequestContainer) | ||
print "CreateShipment_response",response | ||
|
||
ValidateShipmentRequestContainer = client.factory.create('ns0:ValidateShipmentRequestContainer') | ||
ValidateShipmentRequestContainer.Shipment = MyShipment | ||
response2 = client.service.ValidateShipment(ValidateShipmentRequestContainer) | ||
|
||
print "ValidateShipment_response",response2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from suds.client import Client | ||
|
||
|
||
""" | ||
required fields for basic client response : | ||
1.url (different for each service) | ||
development and production environment urls are different.please check with developers guide after creating developer account | ||
2.username - provided by purolator | ||
3.password - provided by purolator | ||
4. Language- currently english and french are supported | ||
5.UserToken - provided with developer account. production account does not need one | ||
6.Version - latest version of particular service. Provided in each pdf of each service's developer guide | ||
""" | ||
|
||
|
||
url = "https://devwebservices.purolator.com/EWS/V1/Estimating/EstimatingService.wsdl" | ||
client = Client(url,username='myusername',password='mypassword') | ||
|
||
Language = client.factory.create('ns0:Language') | ||
|
||
RequestContext = client.factory.create('ns0:RequestContext') | ||
|
||
RequestContext.Version = '1.4' | ||
RequestContext.GroupID = 'xxx' | ||
RequestContext.RequestReference = 'Rating Example' | ||
RequestContext.Language = Language.en | ||
RequestContext.UserToken = 'myusertoken' | ||
print"RequestContext",RequestContext | ||
client.set_options(soapheaders=RequestContext) | ||
print "first client response",client | ||
################################################################################################## | ||
|
||
BillingAccountNumber = 'YOURBILLINGACCOUNTNUMER' | ||
SenderPostalCode = 'L4W5M8' | ||
ReceiverAddress = client.factory.create('ns0:ShortAddress') | ||
ReceiverAddress.City = 'Burnaby' | ||
ReceiverAddress.Province = 'BC' | ||
ReceiverAddress.Country = 'CA' | ||
ReceiverAddress.PostalCode = 'V5C1A1' | ||
PackageType = 'ExpressPack' | ||
TotalWeight = client.factory.create('ns0:TotalWeight') | ||
TotalWeight.Value = 10 | ||
WeightUnit = client.factory.create('ns0:WeightUnit') | ||
TotalWeight.WeightUnit.value = WeightUnit.lb | ||
response = client.service.GetQuickEstimate(BillingAccountNumber,SenderPostalCode,ReceiverAddress,PackageType,TotalWeight) | ||
print ">>>>>>>>response>>>>>>>>",response | ||
################################################################################################## | ||
|
Oops, something went wrong.