Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var shipment = new AddressValidatingShipment
            {
                Confirmation = AddressValidatingShipment.ConfirmationEnum.None,
                CarrierId    = null,
                ServiceCode  = null,

                Packages = new List <ShipmentPackage>
                {
                    new ShipmentPackage
                    {
                        Weight     = new Weight(8, Weight.UnitEnum.Ounce),
                        Dimensions = new Dimensions(Dimensions.UnitEnum.Inch, 5, 5, 5)
                    }
                }
            };

            var apiKey  = GetApiKey();
            var carrier = ChooseCarrier(apiKey);

            shipment.ShipFrom = GetAddress(
                "Where are you shipping FROM?",
                new AddressDTO("John Doe", "5551234567", "Acme Corp.", "100 Main St.", null, null, "Austin", "TX", "78610", "US")
                );

            shipment.ShipTo = GetAddress(
                "Where are you shipping TO?",
                new AddressDTO("John Doe", "5551234567", "Acme Corp.", "100 Main St.", null, null, "Houston", "TX", "77002", "US")
                );

            var rate = ChooseRate(shipment, carrier, apiKey);

            Console.WriteLine("Purchasing label...");
            var isTestLabel = rate.CarrierCode == "stamps_com" || rate.CarrierCode == "endicia";
            var labelsApi   = new LabelsApi();
            var label       = labelsApi.LabelsPurchaseLabelWithRate(rate.RateId, new PurchaseLabelWithoutShipmentRequest(isTestLabel), apiKey);

            Console.WriteLine("Download your label:");
            Console.WriteLine(label.LabelDownload.Href);

            WaitToQuit();
        }