Exemplo n.º 1
0
 /// <remarks/>
 public void getRatesAsync(RateRequest RateRequest, object userState) {
     if ((this.getRatesOperationCompleted == null)) {
         this.getRatesOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetRatesOperationCompleted);
     }
     this.InvokeAsync("getRates", new object[] {
                 RateRequest}, this.getRatesOperationCompleted, userState);
 }
Exemplo n.º 2
0
 private static void SetCOD(RateRequest request)
 {
     // To get all COD rates, set both COD details at both package and shipment level
     // Set COD at Package level for Ground Services
     request.RequestedShipment.RequestedPackageLineItems[0].SpecialServicesRequested = new PackageSpecialServicesRequested
     {
         SpecialServiceTypes = new PackageSpecialServiceType[1]
     };
     request.RequestedShipment.RequestedPackageLineItems[0].SpecialServicesRequested.SpecialServiceTypes[0] = PackageSpecialServiceType.COD;
     //
     request.RequestedShipment.RequestedPackageLineItems[0].SpecialServicesRequested.CodDetail = new CodDetail
     {
         CollectionType = CodCollectionType.GUARANTEED_FUNDS,
         CodCollectionAmount =
             new RateAvailableServiceWebServiceClient.RateServiceWebReference.Money
             {
                 Amount = 250,
                 AmountSpecified = true,
                 Currency = "USD"
             }
     };
     // Set COD at Shipment level for Express Services
     request.RequestedShipment.SpecialServicesRequested = new ShipmentSpecialServicesRequested
     {
         SpecialServiceTypes = new ShipmentSpecialServiceType[1]
     }; // Special service requested
     request.RequestedShipment.SpecialServicesRequested.SpecialServiceTypes[0] = ShipmentSpecialServiceType.COD;
     //
     request.RequestedShipment.SpecialServicesRequested.CodDetail = new CodDetail
     {
         CodCollectionAmount =
             new RateAvailableServiceWebServiceClient.RateServiceWebReference.Money
             {
                 Amount = 150,
                 AmountSpecified = true,
                 Currency = "USD"
             },
         CollectionType = CodCollectionType.GUARANTEED_FUNDS
     };
 }
Exemplo n.º 3
0
 /// <remarks/>
 public void getRatesAsync(RateRequest RateRequest) {
     this.getRatesAsync(RateRequest, null);
 }
Exemplo n.º 4
0
        private static void SetPackageLineItems(RateRequest request, IShipment shipment, decimal totalWeight, int quantity)
        {
            var count = 1;

            for (var i = 0; i < quantity; i++)
            {
                request.RequestedShipment.RequestedPackageLineItems = new RequestedPackageLineItem[1];
                request.RequestedShipment.RequestedPackageLineItems[0] = new RequestedPackageLineItem
                {
                    SequenceNumber = count.ToString(),
                    GroupPackageCount = "1",
                    Weight =
                        new Weight
                        {
                            Units = WeightUnits.LB,
                            UnitsSpecified = true,
                            Value = totalWeight,
                            ValueSpecified = true
                        },
                    Dimensions = new Dimensions
                    {
                        Units = LinearUnits.IN,
                        UnitsSpecified = true
                    }
                };
                count++;

            }
        }
Exemplo n.º 5
0
 private static void SetDestination(RateRequest request, IShipment shipment)
 {
     request.RequestedShipment.Recipient = new Party
     {
         Address =
             new RateAvailableServiceWebServiceClient.RateServiceWebReference.Address
             {
                 StreetLines = new[] { shipment.ToAddress1, shipment.ToAddress2 },
                 StateOrProvinceCode = shipment.ToRegion,
                 PostalCode = shipment.ToPostalCode,
                 CountryCode = shipment.ToCountryCode
             }
     };
 }
Exemplo n.º 6
0
 private static void SetOrigin(RateRequest request, IShipment shipment)
 {
     request.RequestedShipment.Shipper = new Party
     {
         Address =
             new RateAvailableServiceWebServiceClient.RateServiceWebReference.Address
             {
                 StreetLines = new[] { shipment.FromAddress1, shipment.FromAddress2 },
                 StateOrProvinceCode = "WA",//shipment.FromRegion,
                 PostalCode = "98225",//shipment.FromPostalCode,
                 CountryCode = shipment.FromCountryCode
             }
     };
 }
Exemplo n.º 7
0
        private static void SetShipmentDetails(RateRequest request, IShipment shipment, decimal totalWeight, int quantity)
        {
            request.RequestedShipment = new RequestedShipment
            {
                ShipTimestamp = DateTime.Now,
                ShipTimestampSpecified = true,
                DropoffType = DropoffType.REGULAR_PICKUP,
                DropoffTypeSpecified = true,
                PackagingType = PackagingType.YOUR_PACKAGING,
                PackagingTypeSpecified = true
            };

            SetOrigin(request, shipment);

            SetDestination(request, shipment);

            SetPackageLineItems(request, shipment, totalWeight, quantity);

            request.RequestedShipment.RateRequestTypes = new RateRequestType[2];
            request.RequestedShipment.RateRequestTypes[0] = RateRequestType.ACCOUNT;
            request.RequestedShipment.RateRequestTypes[1] = RateRequestType.LIST;

            request.RequestedShipment.PackageCount = quantity.ToString();
            //set to true to request COD shipment
            var isCodShipment = false;
            if (isCodShipment)
                SetCOD(request);
        }
Exemplo n.º 8
0
        private RateRequest RateRequest(IShipment shipment, decimal totalWeight, int quantity)
        {
            // Build the RateRequest
            var request = new RateRequest
            {
                WebAuthenticationDetail =
                    new WebAuthenticationDetail
                    {
                        UserCredential =
                            new WebAuthenticationCredential
                            {
                                Key = "fhbqZrPFKWRe2Ndf",
                                Password = "******"
                            }
                    }
            };

            if (usePropertyFile()) //Set values from a file for testing purposes
            {
                request.WebAuthenticationDetail.UserCredential.Key = getProperty("key");
                request.WebAuthenticationDetail.UserCredential.Password = getProperty("password");
            }

            request.ClientDetail = new ClientDetail { AccountNumber = "510087569", MeterNumber = "118628262" };
            if (usePropertyFile()) //Set values from a file for testing purposes
            {
                request.ClientDetail.AccountNumber = getProperty("accountnumber");
                request.ClientDetail.MeterNumber = getProperty("meternumber");
            }

            request.TransactionDetail = new TransactionDetail
            {
                CustomerTransactionId = "***Rate Available Services v14 Request using VC#***"
            };

            request.Version = new VersionId();

            request.ReturnTransitAndCommit = true;
            request.ReturnTransitAndCommitSpecified = true;

            SetShipmentDetails(request, shipment, totalWeight, quantity);

            return request;
        }