Example #1
0
 /// <summary>
 /// Generate a domestic rate
 /// </summary>
 private static async Task <CalculateRatesResponseBody> GenerateDomesticRate(
     IShipEngineClient client,
     string warehouseId,
     GetCarriersResponseBody carriers)
 {
     return(await client.CalculateRates(new CalculateRatesRequestBody {
         Shipment = new AddressValidatingShipment {
             ValidateAddress = ValidateAddress.NoValidation,
             ShipDate = DateTimeOffset.Now.Date,
             ShipTo = new Address {
                 Name = "Joe Blogs",
                 Phone = "1-530-894-0797",
                 AddressLine1 = "411 Otterson Drive",
                 CityLocality = "Chico",
                 StateProvince = "CA",
                 PostalCode = "95928-8217",
                 CountryCode = "US",
             },
             WarehouseId = warehouseId,
             ReturnTo = new Address {
                 Name = "Online Seller",
                 Phone = "1-530-894-0797",
                 AddressLine1 = "424 Otterson Drive",
                 CityLocality = "Chico",
                 StateProvince = "CA",
                 PostalCode = "95928-8217",
                 CountryCode = "US",
             },
             Packages = new List <Package> {
                 new Package {
                     Weight = new Weight {
                         Value = 1.0,
                         Unit = WeightUnit.Pound,
                     },
                     Dimensions = new Dimensions {
                         Length = 1,
                         Width = 2,
                         Height = 3,
                     },
                 },
             },
         },
         RateOptions = new RateRequestBody {
             CarrierIds = carriers.Carriers.Select(p => p.CarrierId).ToList(),
         },
     }));
 }
Example #2
0
 /// <summary>
 /// Generate an international rate
 /// </summary>
 private static async Task <CalculateRatesResponseBody> GenerateInternationalRate(
     IShipEngineClient client,
     string warehouseId,
     GetCarriersResponseBody carriers)
 {
     return(await client.CalculateRates(new CalculateRatesRequestBody {
         Shipment = new AddressValidatingShipment {
             ValidateAddress = ValidateAddress.NoValidation,
             ShipDate = DateTimeOffset.Now.Date,
             ShipTo = new Address {
                 Name = "Joe Blogs",
                 Phone = "1-530-894-0797",
                 AddressLine1 = "81 Packingston St",
                 CityLocality = "Kew",
                 StateProvince = "VIC",
                 PostalCode = "3101",
                 CountryCode = "AU",
             },
             WarehouseId = warehouseId,
             ReturnTo = new Address {
                 Name = "Online Seller",
                 Phone = "1-530-894-0797",
                 AddressLine1 = "424 Otterson Drive",
                 CityLocality = "Chico",
                 StateProvince = "CA",
                 PostalCode = "95928-8217",
                 CountryCode = "US",
             },
             Packages = new List <Package> {
                 new Package {
                     Weight = new Weight {
                         Value = 1.0,
                         Unit = WeightUnit.Pound,
                     },
                     Dimensions = new Dimensions {
                         Length = 1,
                         Width = 2,
                         Height = 3,
                     },
                 },
             },
             Customs = new InternationalShipmentOptions {
                 Contents = PackageContents.Merchandise,
                 NonDelivery = NonDelivery.ReturnToSender,
                 CustomsItems = new List <CustomsItem> {
                     new CustomsItem {
                         Description = "Product name",
                         Quantity = 2,
                         Value = 42.99,
                         HarmonizedTariffCode = "",
                         CountryOfOrigin = "US",
                         Sku = "PRODUCT_SKU",
                     },
                 },
             },
         },
         RateOptions = new RateRequestBody {
             CarrierIds = carriers.Carriers.Select(p => p.CarrierId).ToList(),
         },
     }));
 }