public void TestAddRemoveShipments()
        {
            var batch         = _client.CreateBatch().Result;
            var shipment      = _client.CreateShipment(_testShipment).Result;
            var otherShipment = _client.CreateShipment(_testShipment).Result;

            while (batch.State != "created")
            {
                batch = _client.GetBatch(batch.Id).Result;
            }

            batch = _client.AddShipmentsToBatch(batch.Id, new[] { shipment, otherShipment }).Result;

            while (batch.Shipments == null)
            {
                batch = _client.GetBatch(batch.Id).Result;
            }
            var shipmentIds = batch.Shipments.Select(ship => ship.Id).ToList();

            Assert.AreEqual(batch.NumShipments, 2);
            CollectionAssert.Contains(shipmentIds, shipment.Id);
            CollectionAssert.Contains(shipmentIds, otherShipment.Id);

            batch = _client.RemoveShipmentsFromBatch(batch.Id, new[] { shipment, otherShipment }).Result;
            Assert.AreEqual(batch.NumShipments, 0);
        }
Beispiel #2
0
        public async Task Initialize()
        {
            _client  = new EasyPostClient("WzJHJ6SoPnBVYu0ae4aIHA");
            _address = new Address
            {
                Company = "Simpler Postage Inc",
                Street1 = "164 Townsend Street",
                Street2 = "Unit 1",
                City    = "San Francisco",
                State   = "CA",
                Country = "US",
                Zip     = "94107",
                Phone   = "1234567890"
            };
            _toAddress = new Address
            {
                Company = "Simpler Postage Inc",
                Street1 = "164 Townsend Street",
                Street2 = "Unit 1",
                City    = "San Francisco",
                State   = "CA",
                Country = "US",
                Zip     = "94107",
            };
            _fromAddress = new Address
            {
                Name    = "Andrew Tribone",
                Street1 = "480 Fell St",
                Street2 = "#3",
                City    = "San Francisco",
                State   = "CA",
                Country = "US",
                Zip     = "94102",
            };

            _shipment = await _client.CreateShipment(new Shipment
            {
                Parcel = new Parcel
                {
                    Length = 8,
                    Width  = 6,
                    Height = 5,
                    Weight = 10,
                },
                ToAddress   = _toAddress,
                FromAddress = _fromAddress,
                Reference   = "ShipmentRef",
            });

            await _client.BuyShipment(_shipment.Id, _shipment.LowestRate().Id);

            _testPickup = new Pickup
            {
                IsAccountAddress = false,
                Address          = _address,
                Shipment         = _shipment,
                MinDatetime      = DateTime.Now,
                MaxDatetime      = DateTime.Now,
            };
        }
Beispiel #3
0
        public void TestPredefinedPackage()
        {
            var parcel = new Parcel {
                Weight = 1.8, PredefinedPackage = "SMALLFLATRATEBOX"
            };
            var shipment = new Shipment {
                Parcel = parcel
            };

            shipment = _client.CreateShipment(shipment).Result;

            Assert.AreEqual(null, shipment.Parcel.Height);
            Assert.AreEqual("SMALLFLATRATEBOX", shipment.Parcel.PredefinedPackage);
        }
Beispiel #4
0
        public void TestRetrieve()
        {
            var fromAddress = new Address {
                Name    = "Andrew Tribone",
                Street1 = "480 Fell St",
                Street2 = "#3",
                City    = "San Francisco",
                State   = "CA",
                Country = "US",
                Zip     = "94102",
            };
            var toAddress = new Address {
                Company = "Simpler Postage Inc",
                Street1 = "164 Townsend Street",
                Street2 = "Unit 1",
                City    = "San Francisco",
                State   = "CA",
                Country = "US",
                Zip     = "94107",
            };
            var shipment = new Shipment {
                ToAddress   = toAddress,
                FromAddress = fromAddress,
                Parcel      = new Parcel {
                    Length = 8,
                    Width  = 6,
                    Height = 5,
                    Weight = 10,
                },
                Reference = "ShipmentRef",
            };

            shipment = _client.CreateShipment(shipment).Result;

            var rate = _client.GetRate(shipment.Rates[0].Id).Result;

            Assert.AreEqual(rate.Id, shipment.Rates[0].Id);

            Assert.IsNotNull(rate.Rate);
            Assert.IsNotNull(rate.Currency);
            Assert.IsNotNull(rate.ListRate);
            Assert.IsNotNull(rate.ListCurrency);
        }
Beispiel #5
0
        private async Task <Shipment> BuyShipment()
        {
            var shipment = await _client.CreateShipment(_testShipment);

            return(await _client.BuyShipment(shipment.Id, shipment.Rates[0].Id));
        }
Beispiel #6
0
        private Shipment BuyShipment()
        {
            var shipment = _client.CreateShipment(_testShipment).Result;

            return(_client.BuyShipment(shipment.Id, shipment.Rates[0].Id).Result);
        }