Skip to content

Commit

Permalink
move client to the right place
Browse files Browse the repository at this point in the history
  • Loading branch information
Sail338 committed Jul 5, 2018
1 parent c1b051e commit c7e8cac
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion garfield/lookup/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def lookup_contact(request):
:param request A query dict from twilio
"""
suspect_number = request.GET.get('Body')
client = Client(local.TWILIO_ACCOUNT_SID,local.TWILIO_AUTH_TOKEN)

if is_valid_number(suspect_number) is False:
error_message = "Error on input %s \nPhone numbers may only contain +[country code] and numeric characters, please check your syntax\n" % (suspect_number)
Expand Down Expand Up @@ -84,6 +83,8 @@ def __init__(self, expression, message):
self.message = message

def is_valid_number(number):

client = Client(local.TWILIO_ACCOUNT_SID,local.TWILIO_AUTH_TOKEN)
try:
response = client.lookups.phone_numbers(number).fetch(type="carrier")
return True
Expand Down

0 comments on commit c7e8cac

Please sign in to comment.