public async Task <bool> ValidateNumber(string phoneNumber) { if (string.IsNullOrWhiteSpace(phoneNumber)) { return(false); } var phone = FormatPhoneNumber(phoneNumber); if (string.IsNullOrEmpty(phone)) { return(false); } var creds = new BasicAWSCredentials(_configuration["SMSAWSCredsAccess"], _configuration["SMSAWSCredsSecret"]); AmazonPinpointClient pinpointClient = null; //with proxy var proxyConfig = _configuration.GetValue <string>("ProxyAddress"); if (string.IsNullOrEmpty(proxyConfig)) { var config = new AmazonPinpointConfig { ProxyHost = proxyConfig, RegionEndpoint = Amazon.RegionEndpoint.USEast1 }; pinpointClient = new AmazonPinpointClient(creds, config); } else { //without proxy pinpointClient = new AmazonPinpointClient(creds, Amazon.RegionEndpoint.USEast1); } PhoneNumberValidateRequest phoneValidateRequest = new PhoneNumberValidateRequest { NumberValidateRequest = new NumberValidateRequest() { PhoneNumber = phone, IsoCountryCode = "US" } }; PhoneNumberValidateResponse phoneValidateResponse = await pinpointClient.PhoneNumberValidateAsync(phoneValidateRequest); if (phoneValidateResponse.HttpStatusCode == HttpStatusCode.OK) { var numberValidateResponse = phoneValidateResponse.NumberValidateResponse; return(numberValidateResponse != null && numberValidateResponse.PhoneTypeCode == 0); } return(false); }
protected IAmazonPinpoint CreateClient(AWSCredentials credentials, RegionEndpoint region) { var config = new AmazonPinpointConfig { RegionEndpoint = region }; Amazon.PowerShell.Utils.Common.PopulateConfig(this, config); this.CustomizeClientConfig(config); var client = new AmazonPinpointClient(credentials, config); client.BeforeRequestEvent += RequestEventHandler; client.AfterResponseEvent += ResponseEventHandler; return(client); }