public RateResponse Send(string serviceUrl) { RateResponse result = new RateResponse(); string xmlToSend = BuildXml(); string responseXml = RateService.SendRequest(serviceUrl, xmlToSend); result.Parse(responseXml); if (globals.DiagnosticsMode) { _logger.LogMessage("FedEx Diagnostics - Request=" + xmlToSend + "<br/>" + System.Environment.NewLine + "<br/>" + System.Environment.NewLine + " Response=" + responseXml); } return(result); }
private List <IShippingRate> RatePackages(List <Shipment> packages) { List <IShippingRate> result = new List <IShippingRate>(); // Loop through packages, getting rates for each package bool allPackagesRated = true; List <ShippingRate> individualRates = new List <ShippingRate>(); foreach (IShipment s in packages) { ShippingRate singlePackageRate = new ShippingRate(); singlePackageRate = RateService.RatePackage(this.GlobalSettings, this._Logger, Settings, s); if (singlePackageRate == null) { allPackagesRated = false; break; } else { if (singlePackageRate.EstimatedCost < 0) { allPackagesRated = false; break; } else { individualRates.Add(singlePackageRate); } } } //we are done with all packages for this shipping type if (allPackagesRated) { decimal total = 0m; foreach (ShippingRate rate in individualRates) { total += rate.EstimatedCost; } if (total > 0m) { if (individualRates.Count > 0) { result.Add( new ShippingRate() { EstimatedCost = total, DisplayName = this.FindNameByServiceCode(this.Settings.ServiceCode), ServiceCodes = this.Settings.ServiceCode.ToString(), ServiceId = this.Id }); } } } return(result); }