/// <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);
 }
Пример #2
0
        /// <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 });
        }
Пример #3
0
        public void Can_Get_The_Origin_Address_From_A_Shipment()
        {
            //// Arrange
            // handled by SetUp

            //// Act
            var origin = _shipment.GetOriginAddress();

            //// Arrange
            Assert.NotNull(origin);
            Assert.IsTrue(((Address)_origin).Equals(origin));
        }
Пример #4
0
        /// <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
            });
        }