private void AddCustomerClassification(RateRequest rateRequest)
 {
     var customerType = new CodeDescriptionType();
     customerType.Code = CustomerTypeCode;
     customerType.Description = CustomerTypeDescription;
     rateRequest.CustomerClassification = customerType;
 }
Example #2
0
 /// <remarks/>
 public void ProcessRateAsync(RateRequest RateRequest) {
     this.ProcessRateAsync(RateRequest, null);
 }
 //, out string requestXML)
 public RateResponse CallUPSRateRequest(string serviceCode, int Qty, int nrBoxes, int itemsInLastBox, string fullBoxWeight, int valuePerFullBox, int valuePerPartialBox, string partialBoxWeight, inv_detl details, string packagingTypeCode, string currencyCode, decimal unitPrice, bool isResidentialAddress)
 {
     var upsService = new RateService();
     var rateResponse = new RateResponse();
     var rateRequest = new RateRequest();
     AddCustomerClassification(rateRequest);
     AddUpsSecurity(upsService);
     var request = new RequestType();
     String[] requestOption = { "Rate" };
     request.RequestOption = requestOption; //this can be Rate or Shop
     rateRequest.Request = request;
     var shipment = new UPSRateService.ShipmentType();
     AddShipper(shipment);
     AddShipFromAddress(shipment);
     AddShipToAddress(shipment, isResidentialAddress);
     var service = new CodeDescriptionType();
     service.Code = serviceCode;
     shipment.Service = service;
     var optype = new UPSRateService.ShipmentRatingOptionsType();
     optype.NegotiatedRatesIndicator = string.Empty;
     shipment.ShipmentRatingOptions = optype;
     AddPackageArray(nrBoxes, itemsInLastBox, fullBoxWeight, partialBoxWeight, valuePerFullBox, valuePerPartialBox, details, packagingTypeCode, currencyCode, shipment);
     AddInvoiceTotalType(Qty, unitPrice, shipment);
     rateRequest.Shipment = shipment;
     //var serializer = new XmlSerializer(typeof(RateRequest));
     //using (var writer = new StringWriter())
     //{
     //  serializer.Serialize(writer, rateRequest);
     //  requestXML = writer.ToString();
     //}
     rateResponse = upsService.ProcessRate(rateRequest);
     return rateResponse;
 }
Example #4
0
 /// <remarks/>
 public void ProcessRateAsync(RateRequest RateRequest, object userState) {
     if ((this.ProcessRateOperationCompleted == null)) {
         this.ProcessRateOperationCompleted = new System.Threading.SendOrPostCallback(this.OnProcessRateOperationCompleted);
     }
     this.InvokeAsync("ProcessRate", new object[] {
                 RateRequest}, this.ProcessRateOperationCompleted, userState);
 }