/*private void AddPaymentInformation(ShipmentType shipment) { var paymentInfo = new PaymentInfoType(); var paymentInfoType = new PaymentType(); paymentInfoType.Code shipper.ShipperNumber = ShipperNumber; shipper.Name = ShipperName; AddShipperAddress(shipper); shipment.Shipper = shipper; }*/ private void AddPackage(int boxWeight, int declaredVal, int boxHeight, int boxWidth, int boxLength, string packagingTypeCode, string currencyCode, PackageType[] pkgArray, int pos) { var package = new PackageType(); var packageWeight = new PackageWeightType(); packageWeight.Weight = boxWeight.ToString(); var uom = new ShipUnitOfMeasurementType(); uom.Code = "LBS"; uom.Description = "pounds"; packageWeight.UnitOfMeasurement = uom; package.PackageWeight = packageWeight; var packageDimensions = new DimensionsType(); packageDimensions.Height = boxHeight.ToString(); packageDimensions.Length = boxLength.ToString(); packageDimensions.Width = boxWidth.ToString(); var packDimType = new ShipUnitOfMeasurementType(); packDimType.Code = "IN"; packDimType.Description = "Inches"; packageDimensions.UnitOfMeasurement = packDimType; package.Dimensions = packageDimensions; var packageServiceOptions = new PackageServiceOptionsType(); var declaredValue = new PackageDeclaredValueType(); declaredValue.CurrencyCode = currencyCode; declaredValue.MonetaryValue = declaredVal.ToString(); packageServiceOptions.DeclaredValue = declaredValue; package.PackageServiceOptions = packageServiceOptions; var packType = new PackagingType(); packType.Code = packagingTypeCode; package.Packaging = packType; pkgArray[pos] = package; }
public ShipmentResponse CallUPSShipmentRequest(string serviceCode, int ShipmentID) { //var dbShipment = ShipmentModule.GetShipmentByID(ShipmentID); var shipmentDetails = ShipmentModule.GetShipmentShipmentDetails(ShipmentID); var shpSvc = new ShipService(); var shipmentRequest = new ShipmentRequest(); AddUpsSecurity(shpSvc); var request = new RequestType(); String[] requestOption = { "1" }; //{ "nonvalidate" }; request.RequestOption = requestOption; shipmentRequest.Request = request; var shipment = new ShipmentType(); shipment.Description = "Ship webservice example"; AddShipper(shipment); AddShipFromAddress(shipment); AddShipToAddress(shipment); AddBillShipperAccount(shipment); //AddPaymentInformation(shipment); var service = new ServiceType(); service.Code = serviceCode; shipment.Service = service; PackageType[] pkgArray; pkgArray = new PackageType[shipmentDetails.Count]; var i = 0; foreach (var box in shipmentDetails) { AddPackage(box.UnitWeight.Value, Convert.ToInt32(box.UnitPrice), box.DimensionH.Value, box.DimensionD.Value, box.DimensionL.Value, PackagingTypeCode, "USD", pkgArray, i); i = i + 1; } shipment.Package = pkgArray; var labelSpec = new LabelSpecificationType(); var labelStockSize = new LabelStockSizeType(); labelStockSize.Height = "3"; labelStockSize.Width = "2"; labelSpec.LabelStockSize = labelStockSize; var labelImageFormat = new LabelImageFormatType(); labelImageFormat.Code = "GIF";//"SPL"; labelSpec.LabelImageFormat = labelImageFormat; shipmentRequest.LabelSpecification = labelSpec; shipmentRequest.Shipment = shipment; var shipmentResponse = shpSvc.ProcessShipment(shipmentRequest); return shipmentResponse; }