mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
add initial phone validation ability
This commit is contained in:
0
app/clients/pinpoint/__init__.py
Normal file
0
app/clients/pinpoint/__init__.py
Normal file
57
app/clients/pinpoint/aws_pinpoint.py
Normal file
57
app/clients/pinpoint/aws_pinpoint.py
Normal file
@@ -0,0 +1,57 @@
|
||||
from boto3 import client
|
||||
from flask import current_app
|
||||
|
||||
from app.clients import AWS_CLIENT_CONFIG, Client
|
||||
from app.cloudfoundry_config import cloud_config
|
||||
from app.utils import hilite
|
||||
|
||||
|
||||
class AwsPinpointClient(Client):
|
||||
|
||||
def init_app(self, current_app, *args, **kwargs):
|
||||
self._client = client(
|
||||
"pinpoint",
|
||||
region_name=cloud_config.sns_region,
|
||||
aws_access_key_id=cloud_config.sns_access_key,
|
||||
aws_secret_access_key=cloud_config.sns_secret_key,
|
||||
config=AWS_CLIENT_CONFIG,
|
||||
)
|
||||
|
||||
super(Client, self).__init__(*args, **kwargs)
|
||||
self.current_app = current_app
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return "pinpoint"
|
||||
|
||||
def validate_phone_number(self, country_code, phone_number):
|
||||
response = self._client.phone_number_validate(
|
||||
NumberValidateRequest={"IsoCountryCode": "string", "PhoneNumber": "string"}
|
||||
)
|
||||
|
||||
# TODO right now this will only print with AWS simulated numbers,
|
||||
# but remove this when that changes
|
||||
current_app.logger.info(hilite(response))
|
||||
|
||||
# TODO This is the structure of the response. When the phone validation
|
||||
# capability we want to offer is better defined (it may just be a question
|
||||
# of checking PhoneType -- i.e., landline or mobile) then do something with
|
||||
# this info.
|
||||
# {
|
||||
# 'NumberValidateResponse': {
|
||||
# 'Carrier': 'string',
|
||||
# 'City': 'string',
|
||||
# 'CleansedPhoneNumberE164': 'string',
|
||||
# 'CleansedPhoneNumberNational': 'string',
|
||||
# 'Country': 'string',
|
||||
# 'CountryCodeIso2': 'string',
|
||||
# 'CountryCodeNumeric': 'string',
|
||||
# 'County': 'string',
|
||||
# 'OriginalCountryCodeIso2': 'string',
|
||||
# 'OriginalPhoneNumber': 'string',
|
||||
# 'PhoneType': 'string',
|
||||
# 'PhoneTypeCode': 123,
|
||||
# 'Timezone': 'string',
|
||||
# 'ZipCode': 'string'
|
||||
# }
|
||||
# }
|
||||
Reference in New Issue
Block a user