Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Africa's talking adapter #70

Conversation

andela-mmakinde
Copy link
Contributor

What does this PR do?

Add Africa's talking sms adapter to the application.

Description of Task to be completed?
Add functionality for SMS to work with Africa's Talking. issue #56

How should this be manually tested?

  • Create an account with Africa's talking, create a team and an app with them and get an API key.
  • Get a shortcode users can send messages to on Africa's talking.
  • Add an sms callback url <host>/sms/africastalking on Africa's talking.
  • Export the variables SMS_AFRICASTALKING_USER and SMS_AFRICASTALKING_KEY.
  • Start the app.
  • Send a request to the shortcode registered and a response will be sent to your mobile number.

Screenshots (if appropriate)
screen_shot_2017-11-15_at_11 51 26_am

bb99352e-ea63-429f-b965-68901c91d5f4

@andela-mmakinde andela-mmakinde force-pushed the add-africas-talking-adapter branch from 5bc08b6 to b08a62e Compare November 15, 2017 14:25
@@ -21,7 +21,7 @@ def get_nurses_from_nc_registry(query):
nurses = {'hits': [], 'total': 0}
try:
response = requests.get(url)
if 'No results' in response.content:
if b'No results' in response.content:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the "b" for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns the text in front of it into a bytes literal.
After updating the app to python3, it throws an error if 'No results' in response.content: TypeError: a bytes-like object is required, not 'str'

AFRICASTALKING = {
"SMS_AFRICASTALKING_USER": os.getenv("SMS_AFRICASTALKING_USER"),
"SMS_AFRICASTALKING_KEY": os.getenv("SMS_AFRICASTALKING_KEY"),
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to MTECH, some 3 things here:

  1. Let's have these as their own variables
  2. env variables must start with HTOOLS_
  3. Use single quotes

@@ -18,7 +18,7 @@ def process_sms(args, adapter='mtech'):
# TODO: Track event SMS RECEIVED here

result, doc_type = run_query(msg)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP 8 check.

'phoneNumber': request.values.get('from'),
'message': request.values.get('text')
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be done in the adapter itself similar to how we've achieved Twilio.

python-3.6.2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andela-ookoro will add this changes in his PR that upgrades to python3

@DavidLemayian
Copy link
Contributor

What's the src/healthtools submodule for?

…Tools.API into add-africas-talking-adapter

 with '#' will be ignored, and an empty message aborts the commit.
 with '#' will be ignored, and an empty message aborts the commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants