Skip to content

Commit

Permalink
added invalid-phone exception, updated .gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
kadenlnelson committed Mar 15, 2019
1 parent bb239c7 commit 0935074
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ doc/_*

*.xlsx

*.log
*.log

*.pyc
2 changes: 2 additions & 0 deletions realvalidation/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def main():
dnc_rows.append(row)
else:
valid_rows.append(row)
# TODO: maybe we could add error data to row array, that way when
# we view the error sheet, we can determine which error triggered
except ResponseCodeNotOkError:
error_rows.append(row)
else:
Expand Down
4 changes: 4 additions & 0 deletions realvalidation/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ class InvalidCustomerError(ResponseCodeNotOkError):

class InsufficientBalanceError(ResponseCodeNotOkError):
pass


class InvalidPhoneError(ResponseCodeNotOkError):
pass
9 changes: 8 additions & 1 deletion realvalidation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from .errors import (
ResponseCodeNotOkError, MissingPhoneNumberError, InsufficientBalanceError,
InvalidCustomerError, InvalidPhoneFormatError
InvalidCustomerError, InvalidPhoneFormatError, InvalidPhoneError
)

import logging
Expand Down Expand Up @@ -78,6 +78,13 @@ def response_raise_for_status(response_code, response_msg):
):
raise InsufficientBalanceError

# invalid phone
elif (
response_code == 'invalid-phone'
and response_msg == 'Phone Number does not exist'
):
raise InvalidPhoneError

# unknown error
else:
raise ResponseCodeNotOkError
Expand Down

0 comments on commit 0935074

Please sign in to comment.