public rateQuote getQuote([System.Xml.Serialization.XmlElementAttribute(Namespace = "http://ws.estesexpress.com/schema/2017/07/ratequote")] rateRequest rateRequest) { object[] results = this.Invoke("getQuote", new object[] { rateRequest }); return((rateQuote)(results[0])); }
/// <remarks/> public void getQuoteAsync(rateRequest rateRequest, object userState) { if ((this.getQuoteOperationCompleted == null)) { this.getQuoteOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetQuoteOperationCompleted); } this.InvokeAsync("getQuote", new object[] { rateRequest }, this.getQuoteOperationCompleted, userState); }
public void getEstesAPI_Rate(string origCountry, string destCountry, List <string> accessorials, ref GCMRateQuote estesQuote) { //string[] res = new string[4]; //define rateService object, makes the request to Estes API, accepts rateRequest object as parameter gcmAPI.Estes_RateWebServ.RateQuoteService rateServ = new gcmAPI.Estes_RateWebServ.RateQuoteService(); gcmAPI.Estes_RateWebServ.rateQuote rateQuote = new gcmAPI.Estes_RateWebServ.rateQuote(); //define rateQuote object, response rate quote gcmAPI.Estes_RateWebServ.rateRequest rateRequest = new gcmAPI.Estes_RateWebServ.rateRequest(); //define rateRequest object, stores iformation about the shipment gcmAPI.Estes_RateWebServ.PricingInfoType[] pricing = new gcmAPI.Estes_RateWebServ.PricingInfoType[1]; //define pricing object stores cost and delivery date and other fields gcmAPI.Estes_RateWebServ.PickupType pickupType = new gcmAPI.Estes_RateWebServ.PickupType(); //pickup date pickupType.date = quoteData.puDate; StringBuilder sb = new StringBuilder(); #region Class and weight gcmAPI.Estes_RateWebServ.BaseCommoditiesType baseCommodities = new gcmAPI.Estes_RateWebServ.BaseCommoditiesType(); gcmAPI.Estes_RateWebServ.BaseCommodityType[] commodTypeArray = new gcmAPI.Estes_RateWebServ.BaseCommodityType[quoteData.m_lPiece.Length]; //for (int i = 0; i < weights.Count; i++) //{ // gcmAPI.Estes_RateWebServ.BaseCommodityType commodType = new gcmAPI.Estes_RateWebServ.BaseCommodityType(); //object that holds one class/weight pair // commodType.@class = Convert.ToDecimal(fClasses[i]); // commodType.weight = weights[i]; // commodTypeArray[i] = commodType; //set class/weight to an item in array or classes/weights //} for (int i = 0; i < quoteData.m_lPiece.Length; i++) { //DB.LogGenera("ESTES", "class", quoteData.m_lPiece[i].FreightClass); //DB.LogGenera("ESTES", "weight", quoteData.m_lPiece[i].Weight.ToString()); gcmAPI.Estes_RateWebServ.BaseCommodityType commodType = new gcmAPI.Estes_RateWebServ.BaseCommodityType(); //object that holds one class/weight pair commodType.@class = Convert.ToDecimal(quoteData.m_lPiece[i].FreightClass); //commodType.weight = quoteData.m_lPiece[i].Weight.ToString(); commodType.weight = Convert.ToInt32(quoteData.m_lPiece[i].Weight).ToString(); commodTypeArray[i] = commodType; //set class/weight to an item in array or classes/weights //DB.LogGenera("ESTES", "weight fixed", commodType.weight); } baseCommodities.commodity = commodTypeArray; //set the classes/weights array to the commodity object rateRequest.Item = baseCommodities; #endregion #region Origin and destination rateRequest.originPoint = new gcmAPI.Estes_RateWebServ.PointType(); rateRequest.originPoint.countryCode = origCountry; rateRequest.originPoint.postalCode = quoteData.origZip; rateRequest.originPoint.city = quoteData.origCity; rateRequest.originPoint.stateProvince = quoteData.origState; rateRequest.destinationPoint = new gcmAPI.Estes_RateWebServ.PointType(); rateRequest.destinationPoint.countryCode = destCountry; rateRequest.destinationPoint.postalCode = quoteData.destZip; rateRequest.destinationPoint.city = quoteData.destCity; rateRequest.destinationPoint.stateProvince = quoteData.destState; if (quoteData.origCountry == "CANADA") { rateRequest.originPoint.postalCode = quoteData.orig_zip_Canada_no_space; } else { //rateRequest.destinationPoint.countryCode = destCountry; } if (quoteData.destCountry == "CANADA") { rateRequest.destinationPoint.postalCode = quoteData.dest_zip_Canada_no_space; } else { rateRequest.destinationPoint.countryCode = destCountry; } sb.Append( string.Concat( rateRequest.originPoint.city, ", ", rateRequest.originPoint.stateProvince, " ", rateRequest.originPoint.postalCode, " ", rateRequest.originPoint.countryCode, " " ) ); sb.Append( string.Concat( rateRequest.destinationPoint.city, ", ", rateRequest.destinationPoint.stateProvince, " ", rateRequest.destinationPoint.postalCode, " ", rateRequest.destinationPoint.countryCode ) ); #endregion //DB.LogGenera("Estes", "request info", sb.ToString()); #region Accessorials if (accessorials == null || accessorials.Count == 0) { rateRequest.accessorials = null; } else { rateRequest.accessorials = new string[accessorials.Count]; for (int i = 0; i < accessorials.Count; i++) { rateRequest.accessorials[i] = accessorials[i]; //HelperFuncs.writeToSiteErrors("Estes acc live", accessorials[i], ""); } } #endregion rateRequest.requestID = " "; rateRequest.account = acctInfo.acctNum; rateRequest.payor = acctInfo.chargeType; rateRequest.terms = acctInfo.terms; rateRequest.pickup = pickupType; rateRequest.liability = "1"; rateRequest.declaredValue = 100; rateRequest.declaredValueSpecified = true; #region Hazmat and stackable //HelperFuncs.writeToSiteErrors("Estes", hazmat.ToString(), ""); rateRequest.hazmatSpecified = true; if (quoteData.isHazmat) { rateRequest.hazmat = gcmAPI.Estes_RateWebServ.YesNoBlankType.Y; } else { rateRequest.hazmat = gcmAPI.Estes_RateWebServ.YesNoBlankType.N; } rateRequest.stackableSpecified = true; //to do ask Bob about this rateRequest.stackable = gcmAPI.Estes_RateWebServ.YesNoBlankType.Y; #endregion rateServ.auth = new gcmAPI.Estes_RateWebServ.AuthenticationType(); rateServ.auth.user = acctInfo.username; rateServ.auth.password = acctInfo.password; // Make the API call rateQuote = rateServ.getQuote(rateRequest); pricing = rateQuote.quote.pricing; DateTime delDate = pricing[0].deliveryDate; decimal discount = pricing[0].totalDiscount; //decimal fuel = pricing[0].accessorialInfo[0].charge; decimal accessorial_charges = 0m; for (byte i = 0; i < pricing[0].accessorialInfo.Length; i++) { accessorial_charges += pricing[0].accessorialInfo[i].charge; } Estes_RateWebServ.CommodityInfoType[] commodity = new Estes_RateWebServ.CommodityInfoType[rateQuote.quote.commodityInfo.Length]; commodity = rateQuote.quote.commodityInfo; //decimal charge = commodity[0].charge; decimal charge = 0m; for (byte i = 0; i < commodity.Length; i++) { charge += commodity[i].charge; } decimal rate = commodity[0].rate; //DB.LogGenera("Estes", "charge", charge.ToString()); decimal buy_rate = charge - discount + accessorial_charges; //DB.LogGenera("Estes", "discount", discount.ToString()); //DB.LogGenera("Estes", "fuel", fuel.ToString()); //DB.LogGenera("Estes", "charge", buy_rate.ToString()); //DB.LogGenera("Estes", "buy rate", buy_rate.ToString()); decimal TotalPrice = charge + accessorial_charges - discount; //rate + if (buy_rate > 0) { //DB.LogGenera("Estes", "got price", pricing[0].standardPrice.ToString()); //estesQuote.TotalPrice = (double)buy_rate; estesQuote.TotalPrice = (double)TotalPrice; estesQuote.Scac = "EXLA"; estesQuote.DeliveryDays = Convert.ToInt32((delDate - quoteData.puDate).TotalDays); estesQuote.DisplayName = "Estes Express - Genera"; estesQuote.CarrierKey = "Estes"; estesQuote.BookingKey = "#1#"; // // Check for hazmat if (quoteData.isHazmat) { estesQuote.TotalPrice += 23; } // liftgate pickup and delivery together addition (when both are present only one charge is added by Estes for some reason) if (quoteData.AccessorialsObj.LGPU && quoteData.AccessorialsObj.LGDEL) { estesQuote.TotalPrice += 10; } } else { DB.LogGenera("Estes", "NO price", ""); } }
/// <remarks/> public void getQuoteAsync(rateRequest rateRequest) { this.getQuoteAsync(rateRequest, null); }