private static void SetAddress(AddressValidationRequest request) { request.AddressesToValidate = new AddressToValidate[3]; request.AddressesToValidate[0] = new AddressToValidate(); request.AddressesToValidate[0].ClientReferenceId = "ClientReferenceId1"; request.AddressesToValidate[0].Address = new Address(); request.AddressesToValidate[0].Address.StreetLines = new String[1] { "100 Nickerson RD" }; request.AddressesToValidate[0].Address.PostalCode = "01752"; request.AddressesToValidate[0].Address.City = "Marlborough"; request.AddressesToValidate[0].Address.StateOrProvinceCode = "MA"; request.AddressesToValidate[0].Address.CountryCode = "US"; // request.AddressesToValidate[1] = new AddressToValidate(); request.AddressesToValidate[1].ClientReferenceId = "ClientReferenceId2"; request.AddressesToValidate[1].Address = new Address(); request.AddressesToValidate[1].Address.StreetLines = new String[1] { "167 PROSPECT HIGHWAY" }; request.AddressesToValidate[1].Address.PostalCode = "2147"; request.AddressesToValidate[1].Address.City = "New SOUTH WALES"; request.AddressesToValidate[1].Address.CountryCode = "AU"; request.AddressesToValidate[2] = new AddressToValidate(); request.AddressesToValidate[2].ClientReferenceId = "ClientReferenceId3"; request.AddressesToValidate[2].Address = new Address(); request.AddressesToValidate[2].Address.StreetLines = new String[2] { "3 WATCHMOOR POINT", "WATCHMOOR ROAD" }; request.AddressesToValidate[2].Address.PostalCode = "GU153AQ"; request.AddressesToValidate[2].Address.City = "CAMBERLEY"; request.AddressesToValidate[2].Address.CountryCode = "GB"; }
private void SetAddress(AddressValidationRequest request) { request.AddressesToValidate = new AddressToValidate[1]; request.AddressesToValidate[0] = new AddressToValidate(); request.AddressesToValidate[0].ClientReferenceId = "ClientReferenceId1"; request.AddressesToValidate[0].Address = new Address(); request.AddressesToValidate[0].Address.StreetLines = new String[3] { _addressBO.Address1, _addressBO.Address2, _addressBO.Address3 }; //if(_addressBO.Address2!="") // request.AddressesToValidate[0].Address.StreetLines = new String[2] { _addressBO.Address2 }; //if (_addressBO.Address3 != "") // request.AddressesToValidate[0].Address.StreetLines = new String[3] { _addressBO.Address3 }; request.AddressesToValidate[0].Address.PostalCode = _addressBO.Zip; request.AddressesToValidate[0].Address.City = _addressBO.City; request.AddressesToValidate[0].Address.StateOrProvinceCode = _addressBO.State; request.AddressesToValidate[0].Address.CountryCode = "US"; // //request.AddressesToValidate[1] = new AddressToValidate(); //request.AddressesToValidate[1].ClientReferenceId = "ClientReferenceId2"; //request.AddressesToValidate[1].Address = new Address(); //request.AddressesToValidate[1].Address.StreetLines = new String[1] { "167 PROSPECT HIGHWAY" }; //request.AddressesToValidate[1].Address.PostalCode = "2147"; //request.AddressesToValidate[1].Address.City = "New SOUTH WALES"; //request.AddressesToValidate[1].Address.CountryCode = "AU"; //request.AddressesToValidate[2] = new AddressToValidate(); //request.AddressesToValidate[2].ClientReferenceId = "ClientReferenceId3"; //request.AddressesToValidate[2].Address = new Address(); //request.AddressesToValidate[2].Address.StreetLines = new String[2] { "3 WATCHMOOR POINT", "WATCHMOOR ROAD" }; //request.AddressesToValidate[2].Address.PostalCode = "GU153AQ"; //request.AddressesToValidate[2].Address.City = "CAMBERLEY"; //request.AddressesToValidate[2].Address.CountryCode = "GB"; }
private static AddressValidationRequest CreateAddressValidationRequest(ShipServiceInfo clsService, AddressInfo clsAddress) { // Build the AddressValidationRequest AddressValidationRequest request = new AddressValidationRequest(); request.WebAuthenticationDetail = new WebAuthenticationDetail(); request.WebAuthenticationDetail.UserCredential = new WebAuthenticationCredential(); request.WebAuthenticationDetail.UserCredential.Key = clsService.AccountKey; request.WebAuthenticationDetail.UserCredential.Password = clsService.AccountPassword; //request.WebAuthenticationDetail.ParentCredential = new WebAuthenticationCredential(); //request.WebAuthenticationDetail.ParentCredential.Key = clsService.AccountKey; //request.WebAuthenticationDetail.ParentCredential.Password = clsService.AccountPassword; request.ClientDetail = new ClientDetail(); request.ClientDetail.AccountNumber = clsService.AccountNumber; request.ClientDetail.MeterNumber = clsService.MeterNumber; request.TransactionDetail = new TransactionDetail(); request.TransactionDetail.CustomerTransactionId = clsService.OrderNumber; // The client will get the same value back in the reply // Version request.Version = new VersionId(); // Creates the Version element with all child elements populated request.InEffectAsOfTimestamp = DateTime.Now; request.InEffectAsOfTimestampSpecified = true; SetAddress(request, clsAddress, clsService.OrderNumber); return(request); }
public void ValidateAddressTest(string currency, string address, bool expected) { var request = new AddressValidationRequest(currency, address); var result = _client.ValidateAddress(request); Assert.NotNull(result); Assert.AreEqual(expected, result.Result); }
public async Task ValidateAddressAsyncTest(string currency, string address, bool expected) { var request = new AddressValidationRequest(currency, address); var result = await _client.ValidateAddressAsync(request); Assert.NotNull(result); Assert.AreEqual(expected, result.Result); }
private static void SetAddress(AddressValidationRequest request, AddressInfo clsAddress, String OrderNumber) { request.AddressesToValidate = new AddressToValidate[1]; request.AddressesToValidate[0] = new AddressToValidate(); request.AddressesToValidate[0].ClientReferenceId = OrderNumber; request.AddressesToValidate[0].Address = new Address(); if (string.IsNullOrEmpty(clsAddress.Line2)) { request.AddressesToValidate[0].Address.StreetLines = new String[1] { RemoveDiacritics.RemoveAccent(clsAddress.Line1) }; } else { request.AddressesToValidate[0].Address.StreetLines = new String[2] { RemoveDiacritics.RemoveAccent(clsAddress.Line1), RemoveDiacritics.RemoveAccent(clsAddress.Line2) }; } request.AddressesToValidate[0].Address.PostalCode = clsAddress.PostalCode; request.AddressesToValidate[0].Address.City = RemoveDiacritics.RemoveAccent(clsAddress.City); request.AddressesToValidate[0].Address.StateOrProvinceCode = clsAddress.State; request.AddressesToValidate[0].Address.CountryCode = clsAddress.CountryCode; #region ###Test Address### /* * request.AddressesToValidate = new AddressToValidate[2]; * request.AddressesToValidate[0] = new AddressToValidate(); * request.AddressesToValidate[0].ClientReferenceId = "ClientReferenceId1"; * request.AddressesToValidate[0].Address = new Address(); * request.AddressesToValidate[0].Address.StreetLines = new String[1] { "100 Nickerson RD" }; * request.AddressesToValidate[0].Address.PostalCode = "01752"; * request.AddressesToValidate[0].Address.City = "Marlborough"; * request.AddressesToValidate[0].Address.StateOrProvinceCode = "MA"; * request.AddressesToValidate[0].Address.CountryCode = "US"; * // * request.AddressesToValidate[1] = new AddressToValidate(); * request.AddressesToValidate[1].ClientReferenceId = "ClientReferenceId2"; * request.AddressesToValidate[1].Address = new Address(); * request.AddressesToValidate[1].Address.StreetLines = new String[2] { "400 S WESTMORELAND AVE", "APT 413" }; * request.AddressesToValidate[1].Address.PostalCode = "90020"; * request.AddressesToValidate[1].Address.City = "LOS ANGELES"; * request.AddressesToValidate[1].Address.CountryCode = "US"; * * //request.AddressesToValidate[2] = new AddressToValidate(); * //request.AddressesToValidate[2].ClientReferenceId = "ClientReferenceId3"; * //request.AddressesToValidate[2].Address = new Address(); * //request.AddressesToValidate[2].Address.StreetLines = new String[2] { "3 WATCHMOOR POINT", "WATCHMOOR ROAD" }; * //request.AddressesToValidate[2].Address.PostalCode = "GU153AQ"; * //request.AddressesToValidate[2].Address.City = "CAMBERLEY"; * //request.AddressesToValidate[2].Address.CountryCode = "GB"; */ #endregion }
private AddressValidationResponse ValidateAddress(Address address) { var req = new AddressValidationRequest(this.Username, this.Password, this.LicenseNumber, address); var jsonReq = JsonConvert.SerializeObject(req); string result = ""; using (var client = new WebClient()) { client.Headers[HttpRequestHeader.ContentType] = "application/json"; result = client.UploadString(this.UpsEndpoint, "POST", jsonReq); } return(JsonConvert.DeserializeObject <AddressValidationResponse>(result)); }
private static AddressValidationRequest CreateAddressValidationRequest() { // Build the AddressValidationRequest AddressValidationRequest request = new AddressValidationRequest(); // request.WebAuthenticationDetail = new WebAuthenticationDetail(); request.WebAuthenticationDetail.UserCredential = new WebAuthenticationCredential(); //request.WebAuthenticationDetail.UserCredential.Key = "Cr0nkpIax2HSog22"; // Replace "XXX" with the Key //request.WebAuthenticationDetail.UserCredential.Password = "******"; // Replace "XXX" with the Password request.WebAuthenticationDetail.UserCredential.Key = "V4bqDWokgOVi4qsy"; // Replace "XXX" with the Key request.WebAuthenticationDetail.UserCredential.Password = "******"; // Replace "XXX" with the Password request.WebAuthenticationDetail.ParentCredential = new WebAuthenticationCredential(); //request.WebAuthenticationDetail.ParentCredential.Key = "Cr0nkpIax2HSog22"; // Replace "XXX" with the Key //request.WebAuthenticationDetail.ParentCredential.Password = "******"; // Replace "XXX" request.WebAuthenticationDetail.ParentCredential.Key = "V4bqDWokgOVi4qsy"; // Replace "XXX" with the Key request.WebAuthenticationDetail.ParentCredential.Password = "******"; // Replace "XXX" if (usePropertyFile()) //Set values from a file for testing purposes { request.WebAuthenticationDetail.UserCredential.Key = getProperty("key"); request.WebAuthenticationDetail.UserCredential.Password = getProperty("password"); request.WebAuthenticationDetail.ParentCredential.Key = getProperty("parentkey"); request.WebAuthenticationDetail.ParentCredential.Password = getProperty("parentpassword"); } // request.ClientDetail = new ClientDetail(); //request.ClientDetail.AccountNumber = "287737831"; // Replace "XXX" with the client's account number //request.ClientDetail.MeterNumber = "106578628"; // Replace "XXX" with the client's meter number request.ClientDetail.AccountNumber = "510087500"; // Replace "XXX" with the client's account number request.ClientDetail.MeterNumber = "118687440"; // Replace "XXX" with the client's meter number if (usePropertyFile()) //Set values from a file for testing purposes { request.ClientDetail.AccountNumber = getProperty("accountnumber"); request.ClientDetail.MeterNumber = getProperty("meternumber"); } // request.TransactionDetail = new TransactionDetail(); request.TransactionDetail.CustomerTransactionId = "***Address Validation Request using VC#***"; // The client will get the same value back in the reply // request.Version = new VersionId(); // Creates the Version element with all child elements populated // request.InEffectAsOfTimestamp = DateTime.Now; request.InEffectAsOfTimestampSpecified = true; // SetAddress(request); // return(request); }
private static void SetAddress(AddressValidationRequest request) { request.AddressesToValidate = new AddressToValidate[4]; request.AddressesToValidate[0] = new AddressToValidate(); request.AddressesToValidate[0].ClientReferenceId = "ClientReferenceId1"; request.AddressesToValidate[0].Address = new Address(); request.AddressesToValidate[0].Address.StreetLines = new String[1] { "100 Nickerson RD" }; request.AddressesToValidate[0].Address.PostalCode = "01752"; request.AddressesToValidate[0].Address.City = "Marlborough"; request.AddressesToValidate[0].Address.StateOrProvinceCode = "MA"; request.AddressesToValidate[0].Address.CountryCode = "US"; // request.AddressesToValidate[1] = new AddressToValidate(); request.AddressesToValidate[1].ClientReferenceId = "ClientReferenceId2"; request.AddressesToValidate[1].Address = new Address(); request.AddressesToValidate[1].Address.StreetLines = new String[1] { "167 PROSPECT HIGHWAY" }; request.AddressesToValidate[1].Address.PostalCode = "2147"; request.AddressesToValidate[1].Address.City = "New SOUTH WALES"; request.AddressesToValidate[1].Address.CountryCode = "AU"; request.AddressesToValidate[2] = new AddressToValidate(); request.AddressesToValidate[2].ClientReferenceId = "ClientReferenceId3"; request.AddressesToValidate[2].Address = new Address(); request.AddressesToValidate[2].Address.StreetLines = new String[1] { "20 Tuxedo Court" }; request.AddressesToValidate[2].Address.PostalCode = "M1G3S5"; //request.AddressesToValidate[2].Address.City = "Scarborough"; request.AddressesToValidate[2].Address.StateOrProvinceCode = "ON"; request.AddressesToValidate[2].Address.CountryCode = "CA"; request.AddressesToValidate[3] = new AddressToValidate(); request.AddressesToValidate[3].ClientReferenceId = "ClientReferenceId4"; request.AddressesToValidate[3].Address = new Address(); request.AddressesToValidate[3].Address.StreetLines = new String[1] { "135 Liberty St." }; request.AddressesToValidate[3].Address.PostalCode = "M6K 1A7"; request.AddressesToValidate[3].Address.City = "Toronto"; request.AddressesToValidate[3].Address.StateOrProvinceCode = "ON"; request.AddressesToValidate[3].Address.CountryCode = "CA"; }
private static AddressValidationRequest CreateAddressValidationRequest(string straddress2, string strzipcode) { // Build the AddressValidationRequest AddressValidationRequest request = new AddressValidationRequest(); // request.WebAuthenticationDetail = new WebAuthenticationDetail(); request.WebAuthenticationDetail.UserCredential = new WebAuthenticationCredential(); request.WebAuthenticationDetail.UserCredential.Key = ""; request.WebAuthenticationDetail.UserCredential.Password = ""; // request.ClientDetail = new ClientDetail(); request.ClientDetail.AccountNumber = ""; request.ClientDetail.MeterNumber = ""; // request.TransactionDetail = new TransactionDetail(); request.TransactionDetail.CustomerTransactionId = "***Address Validation v2 Request using VC#***"; // This is just an echo back // request.Version = new VersionId(); // Creates the Version element with all child elements populated // request.RequestTimestamp = DateTime.Now; // request.Options = new AddressValidationOptions(); request.Options.CheckResidentialStatus = true; request.Options.MaximumNumberOfMatches = "5"; request.Options.StreetAccuracy = AddressValidationAccuracyType.LOOSE; request.Options.DirectionalAccuracy = AddressValidationAccuracyType.LOOSE; request.Options.CompanyNameAccuracy = AddressValidationAccuracyType.LOOSE; request.Options.ConvertToUpperCase = true; request.Options.RecognizeAlternateCityNames = true; request.Options.ReturnParsedElements = true; // request.AddressesToValidate = new AddressToValidate[1]; request.AddressesToValidate[0] = new AddressToValidate(); request.AddressesToValidate[0].AddressId = "LM"; request.AddressesToValidate[0].Address = new Address(); request.AddressesToValidate[0].Address.StreetLines = new String[1] { straddress2 }; request.AddressesToValidate[0].Address.PostalCode = strzipcode; request.AddressesToValidate[0].CompanyName = "LM"; return(request); }
public void AddressValidationRequestConstruktor() { var obj = new AddressValidationRequest("btc", "address"); Assert.AreEqual("btc", obj.Currency); Assert.AreEqual("address", obj.Address); Assert.True(obj.IsValidationAvailable); obj = new AddressValidationRequest("dash", "someAddress"); Assert.False(obj.IsValidationAvailable); obj = new AddressValidationRequest("ltc", "someAddress"); Assert.False(obj.IsValidationAvailable); obj = new AddressValidationRequest(CurrencyAddressValidationEnum.adx, "SomeAddress"); Assert.AreEqual("adx", obj.Currency); Assert.AreEqual("SomeAddress", obj.Address); Assert.True(obj.IsValidationAvailable); }
private static AddressValidationRequest CreateAddressValidationRequest() { // Build the AddressValidationRequest AddressValidationRequest request = new AddressValidationRequest(); // request.WebAuthenticationDetail = new WebAuthenticationDetail(); request.WebAuthenticationDetail.UserCredential = new WebAuthenticationCredential(); request.WebAuthenticationDetail.UserCredential.Key = "XXXXXX"; // Replace "XXX" with the Key request.WebAuthenticationDetail.UserCredential.Password = "******"; // Replace "XXX" with the Password request.WebAuthenticationDetail.ParentCredential = new WebAuthenticationCredential(); request.WebAuthenticationDetail.ParentCredential.Key = "XXXXXX"; // Replace "XXX" with the Key request.WebAuthenticationDetail.ParentCredential.Password = "******"; // Replace "XXX" if (usePropertyFile()) //Set values from a file for testing purposes { request.WebAuthenticationDetail.UserCredential.Key = getProperty("key"); request.WebAuthenticationDetail.UserCredential.Password = getProperty("password"); request.WebAuthenticationDetail.ParentCredential.Key = getProperty("parentkey"); request.WebAuthenticationDetail.ParentCredential.Password = getProperty("parentpassword"); } // request.ClientDetail = new ClientDetail(); request.ClientDetail.AccountNumber = "XXXXXX"; // Replace "XXX" with the client's account number request.ClientDetail.MeterNumber = "XXXXXX"; // Replace "XXX" with the client's meter number if (usePropertyFile()) //Set values from a file for testing purposes { request.ClientDetail.AccountNumber = getProperty("accountnumber"); request.ClientDetail.MeterNumber = getProperty("meternumber"); } // request.TransactionDetail = new TransactionDetail(); request.TransactionDetail.CustomerTransactionId = "***Address Validation Request using VC#***"; // The client will get the same value back in the reply // request.Version = new VersionId(); // Creates the Version element with all child elements populated // request.InEffectAsOfTimestamp = DateTime.Now; request.InEffectAsOfTimestampSpecified = true; // SetAddress(request); // return(request); }
//private AddressValidationRequest AddressValidateRequest() //{ // return CreateAddressValidationRequest(); //} //private AddressValidationReply AddressValidationReply(AddressValidationRequest request) //{ // AddressValidationService service = new AddressValidationService(); // return service.addressValidation(request); //} //public void Initilise() //{ //} private AddressValidationRequest CreateAddressValidationRequest() { // Build the AddressValidationRequest AddressValidationRequest request = new AddressValidationRequest(); // request.WebAuthenticationDetail = new WebAuthenticationDetail(); request.WebAuthenticationDetail.UserCredential = new WebAuthenticationCredential(); request.WebAuthenticationDetail.UserCredential.Key = _configBO.FedexUserKey.Trim(); //"IoXBEjJlfQOOLlrx"; // Replace "XXX" with the Key request.WebAuthenticationDetail.UserCredential.Password = _configBO.FedexUserPassword.Trim(); //"uwcmw4WV7TpoeZ0hOvK1jy9fF"; // Replace "XXX" with the Password request.WebAuthenticationDetail.ParentCredential = new WebAuthenticationCredential(); request.WebAuthenticationDetail.ParentCredential.Key = _configBO.FedexParentKey.Trim(); //"IoXBEjJlfQOOLlrx"; // Replace "XXX" with the Key request.WebAuthenticationDetail.ParentCredential.Password = _configBO.FedexParentPassword.Trim(); //"uwcmw4WV7TpoeZ0hOvK1jy9fF"; // Replace "XXX" if (usePropertyFile()) //Set values from a file for testing purposes { request.WebAuthenticationDetail.UserCredential.Key = getProperty("key"); request.WebAuthenticationDetail.UserCredential.Password = getProperty("password"); request.WebAuthenticationDetail.ParentCredential.Key = getProperty("parentkey"); request.WebAuthenticationDetail.ParentCredential.Password = getProperty("parentpassword"); } // request.ClientDetail = new ClientDetail(); request.ClientDetail.AccountNumber = Convert.ToString(_configBO.FedexACNo); //"510088000"; // Replace "XXX" with the client's account number request.ClientDetail.MeterNumber = Convert.ToString(_configBO.FedexMeterNo); // "118817920"; // Replace "XXX" with the client's meter number if (usePropertyFile()) //Set values from a file for testing purposes { request.ClientDetail.AccountNumber = getProperty("accountnumber"); request.ClientDetail.MeterNumber = getProperty("meternumber"); } // request.TransactionDetail = new TransactionDetail(); request.TransactionDetail.CustomerTransactionId = "***Address Validation Request using VC#***"; // The client will get the same value back in the reply // request.Version = new VersionId(); // Creates the Version element with all child elements populated // request.InEffectAsOfTimestamp = DateTime.Now; request.InEffectAsOfTimestampSpecified = true; // SetAddress(request); // return(request); }
static void Main(string[] args) { AddressValidationRequest request = CreateAddressValidationRequest(); // AddressValidationService service = new AddressValidationService(); if (usePropertyFile()) { service.Url = getProperty("endpoint"); } // try { // Call the AddressValidationService passing in an AddressValidationRequest and returning an AddressValidationReply AddressValidationReply reply = service.addressValidation(request); // if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING) { ShowAddressValidationReply(reply); } else { foreach (Notification notification in reply.Notifications) { Console.WriteLine(notification.Message); } } } catch (SoapException e) { Console.WriteLine(e.Detail.InnerText); } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine("Press any key to quit!"); Console.ReadKey(); }
public AddressValitationResponse ValidateAddress(AddressValidationRequest request) { return(AddressValitationResponseErrorHandle(DoRequest(GetAddressValidationQueryString(request)))); }
protected void FEDEX(Person p) { string straddress2 = p.Addr1; string strzipcode = p.Zip5; string address = string.Empty; string zipfour = string.Empty; string ststate = string.Empty; string zip = string.Empty; string[] split = null; string delimStr = "-"; char[] delimiter = delimStr.ToCharArray(); btn2Submit.Enabled = true; lblAVS_Shipping.Visible = false; AddressValidationRequest request = CreateAddressValidationRequest(straddress2, strzipcode); // AddressValidationService addressValidationService = new AddressValidationService(); // try { // This is the call to the web service passing in an AddressValidationRequest and returning an AddressValidationReply AddressValidationReply reply = addressValidationService.addressValidation(request); // int score = Convert.ToInt32(reply.AddressResults[0].ProposedAddressDetails[0].Score); if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING) { foreach (AddressValidationResult result in reply.AddressResults) { foreach (ProposedAddressDetail detail in result.ProposedAddressDetails) { address = detail.Address.StreetLines[0]; zip = detail.Address.PostalCode; split = zip.Split(delimiter); zip = split[0]; //zipfour = split[1]; } if (score < 20)//(split.Length<2) (zipfour == null || zipfour.Length < 4) { lblAVS_Shipping.Text = "Address Not Found (FedEx)"; btn2Submit.Enabled = false; lblAVS_Shipping.Visible = true; } else { lblAVS_Shipping.Text = "SUCCESS"; btn2Submit.Enabled = true; lblAVS_Shipping.Visible = false; } } } else { foreach (Notification notification in reply.Notifications) { lblAVS_Shipping.Text = notification.Message; } } } catch (Exception ex) { //yma add this since fedex return exception when no valid address found lblAVS_Shipping.Text = "Address Not Found (FedEx)"; btn2Submit.Enabled = false; lblAVS_Shipping.Visible = true; //Write to log Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry logEnt = new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry(); logEnt.Message = "\r\n" + "FedEx Address Verification error." + "\r\n" + "Source: " + ex.Source + "\r\n" + "Description: " + ex.Message + "\r\n" + "Stack Trace: " + ex.StackTrace; Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(logEnt, "Logs"); } }
private string GetAddressValidationQueryString(AddressValidationRequest request) { return($"{ApiEndPoints.Validation}address?currency={request.Currency}&address={request.Address}"); }
protected void FEDEX(Person p) { string straddress2 = p.Addr1; string strzipcode = p.Zip5; string address = string.Empty; string zipfour = string.Empty; string ststate = string.Empty; string zip = string.Empty; string[] split = null; string delimStr = "-"; char[] delimiter = delimStr.ToCharArray(); //btn2Submit.Enabled = true; lblAVS_Shipping.Visible = false; this.divVerifyErrDisplay.Visible = false; AddressValidationRequest request = CreateAddressValidationRequest(straddress2, strzipcode); // AddressValidationService addressValidationService = new AddressValidationService(); // try { // This is the call to the web service passing in an AddressValidationRequest and returning an AddressValidationReply AddressValidationReply reply = addressValidationService.addressValidation(request); // int score = Convert.ToInt32(reply.AddressResults[0].ProposedAddressDetails[0].Score); if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING) { foreach (AddressValidationResult result in reply.AddressResults) { foreach (ProposedAddressDetail detail in result.ProposedAddressDetails) { address = detail.Address.StreetLines[0]; zip = detail.Address.PostalCode; split = zip.Split(delimiter); zip = split[0]; //zipfour = split[1]; } if (score < 20) //(split.Length<2) (zipfour == null || zipfour.Length < 4) { lblAVS_Shipping.Text = "Address Not Found"; //intentionally missing period so I can tell if its usps or fedex //btn2Submit.Enabled = false; lblAVS_Shipping.Visible = true; this.divVerifyErrDisplay.Visible = true; } else { lblAVS_Shipping.Text = "SUCCESS"; //btn2Submit.Enabled = true; lblAVS_Shipping.Visible = false; this.divVerifyErrDisplay.Visible = false; } } } else { foreach (Notification notification in reply.Notifications) { lblAVS_Shipping.Text = notification.Message; } } } catch (Exception ex) { } }
public AddressServiceResponse ValidationServiceClient(ShipServiceInfo clsService, AddressInfo clsAddress) { string ClassificationType = string.Empty; string serviceURL = string.Empty; AddressValidationService service = new AddressValidationService(); F21.Service.AddressServiceResponse fedExResponse = new F21.Service.AddressServiceResponse(); try { if (F21.Framework.ConfigManager.GetAppSetting2("mode").Equals("production", StringComparison.OrdinalIgnoreCase)) { serviceURL = F21.Framework.ConfigManager.GetAppSetting2("Live_FedExAddressUrl"); } else { serviceURL = F21.Framework.ConfigManager.GetAppSetting2("Test_FedExAddressUrl"); } if (string.IsNullOrEmpty(serviceURL)) { fedExResponse.isSuccess = false; fedExResponse.ErrorMessage = "Address validation service url is empty."; return(fedExResponse); } AddressValidationRequest request = CreateAddressValidationRequest(clsService, clsAddress); // Test URL : https://wsbeta.fedex.com:443/web-services/addressvalidation service.Url = serviceURL; AddressValidationReply reply = service.addressValidation(request); if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING) { //FedExAddressClassificationType Enum fedExResponse = ShowAddressValidationReply(reply); fedExResponse.HighestSeverity = reply.HighestSeverity.ToString(); fedExResponse.isSuccess = true; fedExResponse.ErrorMessage = ""; } else { fedExResponse.HighestSeverity = reply.HighestSeverity == null ? "" : reply.HighestSeverity.ToString(); fedExResponse.isSuccess = false; foreach (Notification notification in reply.Notifications) { System.Diagnostics.Debug.WriteLine(notification.Message); fedExResponse.ErrorMessage = notification.Message; } } } catch (System.Web.Services.Protocols.SoapException ex) { throw ex; } catch (System.ServiceModel.CommunicationException ex) { throw ex; } catch (Exception ex) { throw ex; } return(fedExResponse); }
public string Result() { string FinalResult = "no"; bool isContrySupported = false; bool isResolved = false; AddressValidationRequest request = CreateAddressValidationRequest(); // AddressValidationService service = new AddressValidationService(); if (usePropertyFile()) { service.Url = getProperty("endpoint"); } // try { // Call the AddressValidationService passing in an AddressValidationRequest and returning an AddressValidationReply AddressValidationReply reply = service.addressValidation(request); // if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING) { //ShowAddressValidationReply(reply); foreach (AddressValidationResult result in reply.AddressResults) { //Console.WriteLine("Address Id : " + result.ClientReferenceId); // if (result.ClassificationSpecified) { Console.WriteLine("Classification: " + result.Classification); } // if (result.StateSpecified) { Console.WriteLine("State: " + result.State); } // Console.WriteLine("Proposed Address--"); // Address address = result.EffectiveAddress; // foreach (String street in address.StreetLines) // { // Console.WriteLine(" Street: " + street); // } // Console.WriteLine(" City: " + address.City); // Console.WriteLine(" ST/PR: " + address.StateOrProvinceCode); // Console.WriteLine(" Postal: " + address.PostalCode); // Console.WriteLine(" Country: " + address.CountryCode); // Console.WriteLine(); // Console.WriteLine("Address Attributes:"); foreach (AddressAttribute attribute in result.Attributes) { if (attribute.Name == "CountrySupported" && attribute.Value == "true") { isContrySupported = true; } else if (attribute.Name == "Resolved" && attribute.Value == "true") { isResolved = true; } //Console.WriteLine(" " + attribute.Name + ": " + attribute.Value); } } } else { // foreach (Notification notification in reply.Notifications) // Console.WriteLine(notification.Message); } } catch (SoapException e) { // Console.WriteLine(e.Detail.InnerText); } catch (Exception e) { // Console.WriteLine(e.Message); } // Console.WriteLine("Press any key to quit!"); //Console.ReadKey(); if (isContrySupported && isResolved) { FinalResult = "yes"; } return(FinalResult); }
public async Task <ActionResult <AddressValidationResult> > ValidateAddress([FromBody] AddressValidationRequest request) { var result = await _addressValidationService.ValidateAddressAsync(request.Address, request.StoreId); return(Ok(result)); }
public void IsCurrencyValidationAvailable(string currency, bool expected) { var request = new AddressValidationRequest(currency, "SomeAdress"); Assert.AreEqual(expected, request.IsValidationAvailable); }
public async Task <AddressValitationResponse> ValidateAddressAsync(AddressValidationRequest request) { IRestResponse response = await DoRequestAsync(GetAddressValidationQueryString(request)); return(AddressValitationResponseErrorHandle(response)); }