/// <summary> /// Adds a <see cref="IShipment"/> to the extended data collection /// </summary> /// <param name="extendedData"></param> /// <param name="shipment"></param> public static void AddShipment(this ExtendedDataCollection extendedData, IShipment shipment) { extendedData.AddAddress(shipment.GetOriginAddress(), Constants.ExtendedDataKeys.ShippingOriginAddress); extendedData.AddAddress(shipment.GetDestinationAddress(), Constants.ExtendedDataKeys.ShippingDestinationAddress); extendedData.SetValue(Constants.ExtendedDataKeys.ShipMethodKey, shipment.ShipMethodKey.ToString()); extendedData.AddLineItemCollection(shipment.Items); }
/// <summary> /// Creates a cache key for caching <see cref="IShipmentRateQuote"/>s /// </summary> /// <param name="shipment"> /// The shipment. /// </param> /// <param name="shippingGatewayMethod"> /// The shipping Gateway Method. /// </param> /// <returns> /// The cache key. /// </returns> protected static string GetShipmentRateQuoteCacheKey(IShipment shipment, IShippingGatewayMethod shippingGatewayMethod) { var address = shipment.GetDestinationAddress(); var args = string.Format("{0}.{1}", address.Region.Replace(" ", string.Empty), address.CountryCode); return(Cache.CacheKeys.ShippingGatewayProviderShippingRateQuoteCacheKey(shipment.Key, shippingGatewayMethod.ShipMethod.Key, shipment.VersionKey, args)); }
/// <summary> /// Maps <see cref="IShipment"/> origin and destination addresses to an array of <see cref="TaxAddress"/> for the GetTax request. /// </summary> /// <param name="shipment"> /// The shipment. /// </param> /// <param name="startAddressIndex"> /// The start address index. /// </param> /// <returns> /// The <see cref="TaxAddress[]"/>. /// </returns> public static TaxAddress[] GetTaxAddressArray(this IShipment shipment, int startAddressIndex = 1) { var origin = shipment.GetOriginAddress().ToTaxAddress() as TaxAddress; origin.AddressCode = startAddressIndex.ToString(CultureInfo.InvariantCulture).PadLeft(2, '0'); var destination = shipment.GetDestinationAddress().ToTaxAddress() as TaxAddress; destination.AddressCode = (startAddressIndex + 1).ToString(CultureInfo.InvariantCulture).PadLeft(2, '0'); return(new[] { origin, destination }); }
public void Can_Get_The_Destination_Address_From_A_Shipment() { //// Arrange // handled by SetUp //// Act var destination = _shipment.GetDestinationAddress(); //// Arrange Assert.NotNull(destination); Assert.IsTrue(((Address)_destination).Equals(destination)); }
/// <summary> /// Clones a shipment /// </summary> /// <param name="org"> /// The org. /// </param> /// <returns> /// The <see cref="IShipment"/>. /// </returns> /// <remarks> /// http://issues.merchello.com/youtrack/issue/M-458 /// </remarks> internal static IShipment Clone(this IShipment org) { var lineItemCollection = new LineItemCollection(); foreach (var li in org.Items) { lineItemCollection.Add(li.AsLineItemOf <OrderLineItem>()); } return(new Shipment(org.ShipmentStatus, org.GetOriginAddress(), org.GetDestinationAddress(), lineItemCollection) { ShipmentNumberPrefix = org.ShipmentNumberPrefix, ShipmentNumber = org.ShipmentNumber, ShippedDate = org.ShippedDate, TrackingCode = org.TrackingCode, Carrier = org.Carrier, ShipMethodKey = org.ShipMethodKey, Phone = org.Phone, Email = org.Email }); }
/// <summary> /// Creates a cache key for caching <see cref="IShipmentRateQuote"/>s /// </summary> /// <param name="shipment"> /// The shipment. /// </param> /// <param name="shippingGatewayMethod"> /// The shipping Gateway Method. /// </param> /// <returns> /// The cache key. /// </returns> protected static string GetShipmentRateQuoteCacheKey(IShipment shipment, IShippingGatewayMethod shippingGatewayMethod) { var address = shipment.GetDestinationAddress(); var args = address.Region.IsNullOrWhiteSpace() ? address.CountryCode : string.Format("{0}.{1}", address.Region.Replace(" ", string.Empty), address.CountryCode); return Cache.CacheKeys.ShippingGatewayProviderShippingRateQuoteCacheKey(shipment.Key, shippingGatewayMethod.ShipMethod.Key, shipment.VersionKey, args); }