예제 #1
0
        public static IPostageRatesResponse GetPostageRates(IPostageRatesRequest request, ILogger logger = null)
        {
            string message;
            IPostageRatesResponse postageRatesResponse;

            try
            {
                EwsLabelService client = new EwsLabelService();
                postageRatesResponse = PostageRatesClass.ConstructPostageRatesResponse(client.CalculatePostageRates(PostageRatesClass.ConstructPostageRatesRequest(request)));
            }
            catch (BadRequestException badRequestException)
            {
                message = string.Format("Endicia::Invoker::GetPostageRates Failed({0}).", badRequestException.Message);
                Logger.ExternalLogDebug(logger, message);
                throw;
            }
            catch (Exception exception)
            {
                Exception ex = exception;
                message = string.Format("Endicia::Invoker::GetPostageRates Failed({0}).", ex.Message);
                Logger.ExternalLogDebug(logger, message);
                throw new Exception(message, ex);
            }
            return(postageRatesResponse);
        }
예제 #2
0
        internal static PostageRatesRequest ConstructPostageRatesRequest(IPostageRatesRequest request)
        {
            PostageRatesRequest result = new PostageRatesRequest()
            {
                RequesterID = ToolsClass.GetRequesterID
            };
            CertifiedIntermediary certifiedIntermediary = new CertifiedIntermediary()
            {
                AccountID  = request.AccountID,
                PassPhrase = request.PassPhrase
            };

            result.CertifiedIntermediary = certifiedIntermediary;
            result.MailClass             = Parsers.ParseLabelType(request.MailClass);
            result.DateAdvance           = ConfigManager.Current.DefaultDateAdvance;
            result.Machinable            = ConfigManager.Current.DefaultMachinable;
            SpecialServices specialService = new SpecialServices()
            {
                DeliveryConfirmation    = ToolsClass.ParseBoolONOFF(request.DeliveryConfirmation),
                SignatureConfirmation   = ToolsClass.ParseBoolONOFF(request.SignatureConfirmation),
                CertifiedMail           = ConfigManager.Current.DefaultCertifiedMail,
                RestrictedDelivery      = ConfigManager.Current.DefaultRestrictedDelivery,
                ReturnReceipt           = ConfigManager.Current.DefaultReturnReceipt,
                ElectronicReturnReceipt = ConfigManager.Current.DefaultElectornicReturnReceipt,
                HoldForPickup           = ConfigManager.Current.DefaultHoldForPickup,
                OpenAndDistribute       = ConfigManager.Current.DefaultOpenAndDistribute,
                COD            = ConfigManager.Current.DefaultCOD,
                InsuredMail    = Parsers.ParseInsuredMail(request.InsuredMail),
                AdultSignature = ConfigManager.Current.DefaultAdultSignature,
                AdultSignatureRestrictedDelivery = ConfigManager.Current.DefaultAdultSignatureRestrictedDelivery
            };

            result.Services       = specialService;
            result.InsuredValue   = request.OrderValueForInsurance;
            result.FromPostalCode = request.FromPostalCode;
            result.ToPostalCode   = request.TargetAddress.PostalCode;
            result.ToCountry      = request.TargetAddress.Country;
            result.ToCountryCode  = request.TargetAddress.CountryCode;
            result.WeightOz       = request.PackageDetails.WeightOz;
            Dimensions dimension = new Dimensions()
            {
                Height = request.PackageDetails.Height,
                Length = request.PackageDetails.Length,
                Width  = request.PackageDetails.Width
            };

            result.MailpieceDimensions = dimension;
            return(result);
        }
예제 #3
0
 internal IPostageRatesResponse GetPostageRatesResponse(string accountID, string passPhrase, string fromPostalCode, double OrderValueForInsurance,
                                                        decimal packageHeight, decimal packageWidth, decimal packageLength, decimal packageWeight,
                                                        string address1, string address2, string city, string country, string company, string twoLetterCountryCode, string email,
                                                        string name, string phone, string zipPostalCode, string state, bool isInternational, bool isInsuredMail)
 {
     try
     {
         IPostageRatesRequest request = GetPostageRatesRequest(accountID, passPhrase, fromPostalCode, OrderValueForInsurance,
                                                               packageHeight, packageWidth, packageLength, packageWeight,
                                                               address1, address2, city, country, company, twoLetterCountryCode, email,
                                                               name, phone, zipPostalCode, state, isInternational, isInsuredMail);
         return(Invoker.GetPostageRates(request));
     }
     catch (Exception)
     {
         // Log
         return(null);
     }
 }