Implementing the ITrackAdapter Interface |
The tracking adapter can be used to integrate external applications or services that provide tracking information for a carrier.
Click here for a list of all members of the ITrackAdapter interface.
Note |
---|
See IAdapterConfigurationProvider for a sample implementation of IAdapterConfigurationProvider. All Adapters must have this configuration interface implemented in order for the adapter to function. |
Below is a sample implementation of ITrackAdapter
using System; using System.Collections.Generic; using PSI.Sox; using PSI.Sox.Adapter.Interfaces; using PSI.Sox.Interfaces; using PSI.Sox.Tracking; namespace MockTrackingAdapter { public class Tracking : ITrackAdapter { private string _adapterName = "PSI Mock Track Adapter"; private string _adapterSymbol = "PSI.SOX.MOCKTRACKING"; public string AdapterSymbol { get { return _adapterSymbol; } } public Version AdapterVersion { get { return new Version("1.1"); } } public Guid AdapterId { get { return new Guid("95E87BF1-8ED7-4ACD-95A2-60602F7977C0"); } } public string CompanyName { get { return "UPS Professional Services Inc"; } } public IAdapterConfiguration AdapterConfiguration { get; set; } public string AdapterName { get { return _adapterName; } } public ILogger Logger { get; set; } public IProxySettings ProxySettings { get; set; } public void Dispose() { } public void Init() { } public TrackingResponse Track(TrackingRequest trackingRequest) { TrackingResponse trackResponse = new TrackingResponse(); trackResponse.TrackingNumber = trackingRequest.TrackingNumber; trackResponse.ServiceLevel = trackingRequest.Carrier; trackResponse.Origin = new TrackingLocation() { City = "Tempe", StateProvince = "AZ" }; trackResponse.Destination = new TrackingLocation() { City = "Not Here", StateProvince = "KS" }; trackResponse.TrackingMilestones = new List<TrackingMilestone>(); for (int x = 0; x < 20; x++) { TrackingMilestone tm = new TrackingMilestone(); { tm.Date = new Date(); tm.Location = new TrackingLocation() { City = "Tempe" + x, StateProvince = "AZ" + x, CountryIso2 = "US" }; tm.Status = TrackingStatus.InTransit; tm.Time = "12:00:" + x; } trackResponse.TrackingMilestones.Add(tm); } return trackResponse; } } }