Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

UPSShipmentTracker.cs

using Nop.Core.Domain.Shipping;
using Nop.Plugin.Shipping.UPS.Services;
using Nop.Services.Shipping.Tracking;

namespace Nop.Plugin.Shipping.UPS;

/// 
/// Represents the USP shipment tracker
/// 
public class UPSShipmentTracker : IShipmentTracker
{
    #region Fields

    private readonly UPSService _upsService;

    #endregion

    #region Ctor

    public UPSShipmentTracker(UPSService upsService)
    {
        _upsService = upsService;
    }

    #endregion

    #region Methods

    /// 
    /// Get URL for a page to show tracking info (third party tracking page)
    /// 
    /// The tracking number to track
    /// Shipment; pass null if the tracking number is not associated with a specific shipment
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the URL of a tracking page
    /// 
    public Task GetUrlAsync(string trackingNumber, Shipment shipment = null)
    {
        return Task.FromResult($"https://www.ups.com/track?&tracknum={trackingNumber}");
    }

    /// 
    /// Get all shipment events
    /// 
    /// The tracking number to track
    /// Shipment; pass null if the tracking number is not associated with a specific shipment
    /// 
    /// A task that represents the asynchronous operation
    /// The task result contains the list of shipment events
    /// 
    public async Task> GetShipmentEventsAsync(string trackingNumber, Shipment shipment = null)
    {
        var result = new List();

        if (string.IsNullOrEmpty(trackingNumber))
            return result;

        result.AddRange(await _upsService.GetShipmentEventsAsync(trackingNumber));

        return result;
    }

    #endregion
}