/// <summary> /// Get Shipping Method Draft /// </summary> /// <param name="country"></param> /// <param name="state"></param> /// <returns></returns> public ShippingMethodDraft GetShippingMethodDraft(string country = null, string state = null) { int ran = TestingUtility.RandomInt(); string shippingCountry = country ?? TestingUtility.GetRandomEuropeCountry(); string shippingState = state ?? $"{shippingCountry}_State_{TestingUtility.RandomInt()}"; TaxCategory taxCategory = this.CreateNewTaxCategory(shippingCountry, shippingState); ZoneRateDraft zoneRateDraft = this.GetNewZoneRateDraft(shippingCountry, shippingState); ShippingMethodDraft shippingMethodDraft = new ShippingMethodDraft() { Name = $"Dhl_{ran}", Key = $"Dhl_key_{ran}", TaxCategory = new ResourceIdentifier <TaxCategory> { Key = taxCategory.Key }, ZoneRates = new List <ZoneRateDraft>() { zoneRateDraft }, Description = "DHL" }; return(shippingMethodDraft); }
private ZoneRateDraft GetNewZoneRateDraft(string country = null, string state = null) { Zone zone = this.CreateNewZone(country, state); var shippingRate = this.GetShippingRateDraft(); ZoneRateDraft zoneRateDraft = new ZoneRateDraft() { Zone = new ResourceIdentifier <Zone> { Key = zone.Key }, ShippingRates = new List <ShippingRateDraft>() { shippingRate } }; return(zoneRateDraft); }
public ShippingMethodDraft GetShippingMethodDraft(string country = null) { int ran = this.RandomInt(); TaxCategory taxCategory = this.CreateNewTaxCategory(country); ZoneRateDraft zoneRateDraft = this.GetNewZoneRateDraft(country); ShippingMethodDraft shippingMethodDraft = new ShippingMethodDraft() { Name = $"Dhl_{ran}", Key = $"Dhl_key_{ran}", TaxCategory = new ResourceIdentifier <TaxCategory> { Key = taxCategory.Key }, ZoneRates = new List <ZoneRateDraft>() { zoneRateDraft }, Description = "DHL" }; return(shippingMethodDraft); }
public static async Task WithShippingMethodWithZoneRateAndTaxCategory(IClient client, Func <ShippingMethodDraft, ShippingMethodDraft> draftAction, Address address, Func <ShippingMethod, Task> func) { var taxRateDraft = TestingUtility.GetTaxRateDraft(address); var zoneLocation = new Location { Country = address.Country, State = address.State }; await WithZone(client, draft => DefaultZoneWithOneLocation(draft, zoneLocation), async zone => { await WithTaxCategory(client, draft => DefaultTaxCategoryDraftWithTaxRate(draft, taxRateDraft), async taxCategory => { var shippingRate = TestingUtility.GetShippingRateDraft(); var zoneRateDraft = new ZoneRateDraft() { Zone = zone.ToKeyResourceIdentifier(), ShippingRates = new List <ShippingRateDraft>() { shippingRate } }; var shippingMethodDraft = DefaultShippingMethodDraftWithTaxCategory( new ShippingMethodDraft(), taxCategory.ToKeyResourceIdentifier()); shippingMethodDraft.ZoneRates = new List <ZoneRateDraft> { zoneRateDraft }; await WithAsync(client, shippingMethodDraft, draftAction, func); }); }); }