This is a c# .NET solution so you will need to have visual studio 2008 to run it.
Download from http://agentx.info/skiltz.nzpost.zip
Any questions let me know.
c# Example using the nzpost api
skiltz.nzpost.Package Package = new skiltz.nzpost.Package();
Package.height = 3;
Package.length = 3;
Package.thickness = 3;
Package.weight = 3;
Package.Qty = 1;
//Crete new request to NZPOST RateFinder url
skiltz.nzpost.Request Request = new skiltz.nzpost.Request("Wellington", "Auckland");
//Add our shipment package to the request.
//Can add as many as you like.
Request.PackageCollection.Add(Package);
//Get the response from NZPost
skiltz.nzpost.Response Response = new skiltz.nzpost.Response();
Response = Request.GetRate();
//TO:DO Error Handling.
//we could loop through each package and spit out whatever we want
foreach (skiltz.nzpost.Product p in Response.PackageCollection)
{
decimal cost = default(decimal);
cost = p.Cost;
}
gv1.DataSource = Response.PackageCollection;
gv1.DataBind();
Result:
vb.net Example
'Create new package for shipment
Dim Package As New skiltz.nzpost.Package()
Package.height = txtHeight.Text
Package.length = txtLength.Text
Package.thickness = txtThickness.Text
Package.weight = txtWeight.Text
Package.Qty = 1
'Crete new request to NZPOST RateFinder url
Dim Request As New skiltz.nzpost.Request(txtSrc.Text, txtDestination.Text)
'Add our shipment package to the request.
'Can add as many as you like.
Request.PackageCollection.Add(Package)
'Get the response from NZPost
Dim Response As New skiltz.nzpost.Response()
Response = Request.GetRate()
'TO:DO Error Handling.
'we could loop through each package and spit out whatever we want
For Each p As skiltz.nzpost.Product In Response.PackageCollection
Dim cost As Decimal
cost = p.Cost
Next
If you're looking to implement the nzpost api into your application today and need a developer to make it work please send me an email.
1 comment:
Nice work. Good examples.
Post a Comment