public SwedishPostalServiceShippingProvider( string apiKey, ShippingCostCalculator shippingCostCalculator, CustomsHandlingOptions customsHandlingOptions, InsuranceOptions insuranceOptions) { this.apiKey = apiKey; ShippingCostCalculator = shippingCostCalculator; CustomsHandlingOptions = customsHandlingOptions; InsuranceOptions = insuranceOptions; }
public AustraliaPostShippingProvider( string clientId, string secret, ShippingCostCalculator shippingCostCalculator, CustomsHandlingOptions customsHandlingOptions, InsuranceOptions insuranceOptions) { this.clientId = clientId; this.secret = secret; ShippingCostCalculator = shippingCostCalculator; CustomsHandlingOptions = customsHandlingOptions; InsuranceOptions = insuranceOptions; }
public override string GenerateShippingLabelFor(Order order) { var shippingId = GetShippingId(); var shippingCost = ShippingCostCalculator.CalculateFor(order.Recipient.Country, order.Sender.Country, order.TotalWeight); return($"Shipping Id: {shippingId} {Environment.NewLine}" + $"To: {order.Recipient.To} {Environment.NewLine}" + $"Order total: {order.Total} {Environment.NewLine}" + $"Tax: {CustomsHandlingOptions.TaxOptions} {Environment.NewLine}" + $"Shipping Cost: {shippingCost}"); }
public override string GenerateShippingLabelFor(Order order) { var shippingId = GetShippingId(); if (order.Recipient.Country != order.Sender.Country) { throw new NotSupportedException("International shipping not supported"); } var shippingCost = ShippingCostCalculator.CalculateFor(order.Recipient.Country, order.Sender.Country, order.TotalWeight); return($"Shipping Id: {shippingId} {Environment.NewLine}" + $"To: {order.Recipient.To} {Environment.NewLine}" + $"Order total: {order.Total} {Environment.NewLine}" + $"Tax: {CustomsHandlingOptions.TaxOptions} {Environment.NewLine}" + $"Shipping Cost: {shippingCost}"); }
// No state being kept, use static method // Reusable across all application // Use anywhere - call where needed public static ShippingProvider CreateShippingProvider(string country) { #region Create Shipping Provider ShippingProvider shippingProvider; if (country == "Australia") { #region Australia Post Shipping Provider var shippingCostCalculator = new ShippingCostCalculator( internationalShippingFee: 250, extraWeightFee: 500 ) { ShippingType = ShippingType.Standard }; var customsHandlingOptions = new CustomsHandlingOptions { TaxOptions = TaxOptions.PrePaid }; var insuranceOptions = new InsuranceOptions { ProviderHasInsurance = false, ProviderHasExtendedInsurance = false, ProviderRequiresReturnOnDamange = false }; shippingProvider = new AustraliaPostShippingProvider("CLIENT_ID", "SECRET", shippingCostCalculator, customsHandlingOptions, insuranceOptions); #endregion } else if (country == "Sweden") { #region Swedish Postal Service Shipping Provider var shippingCostCalculator = new ShippingCostCalculator( internationalShippingFee: 50, extraWeightFee: 100 ) { ShippingType = ShippingType.Express }; var customsHandlingOptions = new CustomsHandlingOptions { TaxOptions = TaxOptions.PayOnArrival }; var insuranceOptions = new InsuranceOptions { ProviderHasInsurance = true, ProviderHasExtendedInsurance = false, ProviderRequiresReturnOnDamange = false }; shippingProvider = new SwedishPostalServiceShippingProvider("API_KEY", shippingCostCalculator, customsHandlingOptions, insuranceOptions); #endregion } else { throw new NotSupportedException("No shipping provider found for origin country"); } #endregion return(shippingProvider); }