/// <summary> /// Purchase a label for this shipment with the given rate. /// </summary> /// <param name="rate">EasyPost.Rate object to puchase the shipment with.</param> public void Buy(Rate rate) { Buy(rate.id); }
/// <summary> /// Purchase a label for this shipment with the given rate. /// </summary> /// <param name="rate">EasyPost.Rate object to puchase the shipment with.</param> public void Buy(Rate rate) { Buy(rate.carrier, rate.service); }
/// <summary> /// Purchase a label for this shipment with the given rate. /// </summary> /// <param name="rate">EasyPost.Rate object to puchase the shipment with.</param> /// <param name="insuranceValue">The value to insure the shipment for.</param> public void Buy(Rate rate, string insuranceValue = null) { Buy(rate.id, insuranceValue); }
/// <summary> /// Purchase a label for this shipment with the given rate. /// </summary> /// <param name="rate">EasyPost.Rate object to puchase the shipment with.</param> /// <param name="insuranceValue">The value to insure the shipment for.</param> public void Buy(Client client, Rate rate, string insuranceValue = null) { Buy(client, rate.id, insuranceValue); }
public void TestLowestRate() { Rate lowestUSPS = new Rate() { rate = "1.0", carrier = "USPS", service = "ParcelSelect" }; Rate highestUSPS = new Rate() { rate = "10.0", carrier = "USPS", service = "Priority" }; Rate lowestUPS = new Rate() { rate = "2.0", carrier = "UPS", service = "ParcelSelect" }; Rate highestUPS = new Rate() { rate = "20.0", carrier = "UPS", service = "Priority" }; Shipment shipment = new Shipment() { rates = new List<Rate>() { highestUSPS, lowestUSPS, highestUPS, lowestUPS } }; Rate rate = shipment.LowestRate(); Assert.AreEqual(rate, lowestUSPS); rate = shipment.LowestRate(includeCarriers: new List<string>() { "UPS" }); Assert.AreEqual(rate, lowestUPS); rate = shipment.LowestRate(includeServices: new List<string>() { "Priority" }); Assert.AreEqual(rate, highestUSPS); rate = shipment.LowestRate(excludeCarriers: new List<string>() { "USPS" }); Assert.AreEqual(rate, lowestUPS); rate = shipment.LowestRate(excludeServices: new List<string>() { "ParcelSelect" }); Assert.AreEqual(rate, highestUSPS); rate = shipment.LowestRate(includeCarriers: new List<string>() { "FedEx" }); Assert.IsNull(rate); }
/// <summary> /// Purchase a label for this shipment with the given rate. /// </summary> /// <param name="rate">EasyPost.Rate object to puchase the shipment with.</param> public async Task BuyAsync(Rate rate) { await Task.Run(() => Buy(rate)).ConfigureAwait(false); }
/// <summary> /// Purchase a label for this shipment with the given rate. /// </summary> /// <param name="rate">EasyPost.Rate object to puchase the shipment with.</param> public void Buy(Client client, Rate rate) { Buy(client, rate.carrier, rate.service); }