-
Notifications
You must be signed in to change notification settings - Fork 0
/
UPSShipmentTracker.cs
67 lines (53 loc) · 2 KB
/
UPSShipmentTracker.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System.Collections.Generic;
using System.Threading.Tasks;
using Nop.Core.Domain.Shipping;
using Nop.Plugin.Shipping.UPS.Services;
using Nop.Services.Shipping.Tracking;
namespace Nop.Plugin.Shipping.UPS;
/// <summary>
/// Represents the USP shipment tracker
/// </summary>
public class UPSShipmentTracker : IShipmentTracker
{
#region Fields
private readonly UPSService _upsService;
#endregion
#region Ctor
public UPSShipmentTracker(UPSService upsService)
{
_upsService = upsService;
}
#endregion
#region Methods
/// <summary>
/// Get URL for a page to show tracking info (third party tracking page)
/// </summary>
/// <param name="trackingNumber">The tracking number to track</param>
/// <param name="shipment">Shipment; pass null if the tracking number is not associated with a specific shipment</param>
/// <returns>
/// A task that represents the asynchronous operation
/// The task result contains the URL of a tracking page
/// </returns>
public Task<string> GetUrlAsync(string trackingNumber, Shipment shipment = null)
{
return Task.FromResult($"https://www.ups.com/track?&tracknum={trackingNumber}");
}
/// <summary>
/// Get all shipment events
/// </summary>
/// <param name="trackingNumber">The tracking number to track</param>
/// <param name="shipment">Shipment; pass null if the tracking number is not associated with a specific shipment</param>
/// <returns>
/// A task that represents the asynchronous operation
/// The task result contains the list of shipment events
/// </returns>
public async Task<IList<ShipmentStatusEvent>> GetShipmentEventsAsync(string trackingNumber, Shipment shipment = null)
{
var result = new List<ShipmentStatusEvent>();
if (string.IsNullOrEmpty(trackingNumber))
return result;
result.AddRange(await _upsService.GetShipmentEventsAsync(trackingNumber));
return result;
}
#endregion
}