Example #1
0
        private EstimatingProxy.EstimatingService CreateEstimatingService()
        {
            EstimatingProxy.EstimatingService service = new EstimatingProxy.EstimatingService();

            // Setup the credentials for basic authentication
            //TODO : Define the Production (or development) Key and Password
            service.Credentials = new NetworkCredential("d43ca2e274134898bad98950e65cf9b4", "fb+@9VF{");

            // Set the request's context values
            service.RequestContextValue                  = new EstimatingProxy.RequestContext();
            service.RequestContextValue.Version          = "1.4";
            service.RequestContextValue.Language         = EstimatingProxy.Language.en;
            service.RequestContextValue.GroupID          = "";
            service.RequestContextValue.RequestReference = "RequestReference";
            service.RequestContextValue.UserToken        = "Your User Token";
            return(service);
        }
Example #2
0
        public decimal CallGetQuickEstimate(AspNetUser User)
        {
            EstimatingProxy.EstimatingService service = CreateEstimatingService();
            EstimatingProxy.GetQuickEstimateRequestContainer  request  = new EstimatingProxy.GetQuickEstimateRequestContainer();
            EstimatingProxy.GetQuickEstimateResponseContainer response = new EstimatingProxy.GetQuickEstimateResponseContainer();

            // Setup the request to perform a create shipment
            //TODO : Define the Billing account and the account that is registered with PWS
            request.BillingAccountNumber = "9999999999";
            //TODO : Populate the Origin Information
            request.SenderPostalCode = "J2S1H9";
            //TODO : Populate the Desination Information
            request.ReceiverAddress            = new EstimatingProxy.ShortAddress();
            request.ReceiverAddress.City       = User.City;
            request.ReceiverAddress.Country    = "CA";
            request.ReceiverAddress.Province   = User.State;
            request.ReceiverAddress.PostalCode = User.PostalCode;
            request.PackageType            = "ExpressEnvelope";
            request.TotalWeight            = new EstimatingProxy.TotalWeight();
            request.TotalWeight.Value      = 1;
            request.TotalWeight.WeightUnit = EstimatingProxy.WeightUnit.lb;

            try
            {
                // Call the service
                response = service.GetQuickEstimate(request);

                // Display the response
                Display(response.ResponseInformation);
                Display("ShipmentEstimates:", response.ShipmentEstimates);
                return(response.ShipmentEstimates[0].TotalPrice);
            }
            catch (Exception ex)
            {
                Console.WriteLine(" EXCEPTION: {0}", ex.Message);
            }
            return(0);
        }
Example #3
0
        public void CallGetFullEstimate()
        {
            EstimatingProxy.EstimatingService service = CreateEstimatingService();
            EstimatingProxy.GetFullEstimateRequestContainer  request  = new EstimatingProxy.GetFullEstimateRequestContainer();
            EstimatingProxy.GetFullEstimateResponseContainer response = new EstimatingProxy.GetFullEstimateResponseContainer();

            // Setup the request to perform a get full estimate
            request.Shipment = CreateSampleShipment();

            try
            {
                // Call the service
                response = service.GetFullEstimate(request);

                // Display the response
                Display(response.ResponseInformation);
                Display("ShipmentEstimates:", response.ShipmentEstimates);
                Display("ReturnShipmentEstimates:", response.ReturnShipmentEstimates);
            }
            catch (Exception ex)
            {
                Console.WriteLine(" EXCEPTION: {0}", ex.Message);
            }
        }