def incoming_sms(): """Send a dynamic reply to an incoming text message""" # Get the message the user sent our Twilio number body = request.values.get('Body', None) # Start our TwiML response resp = MessagingResponse() # Determine the right reply for this message if body: sms_check = Check(body) if not sms_check.errors: response = send_check(sms_check) if response.status_code == 201: resp.message("The check was sent.") else: print("Checkbook.io API response info:") print(body) print(response.text) print(sms_check.checkbook_post_data()) print(response.status_code) resp.message("API call was not successful.") else: print("Message parsing errors:") print(sms_check.errors) resp.message("Check is not valid." + str(sms_check.errors)) return str(resp)
def test_valid_check(self): msg = "Send $5 to John Snow ([email protected]) for The Night Watch" expected = { "name": 'John Snow', "recipient": '*****@*****.**', "amount": 5.0, "description": "The Night Watch" } c = Check(msg) self.assertEqual(c.checkbook_post_data(), expected)