def get_response(self, message, **kwargs): response = MessagingResponse() response_text = self.get_response_text() if response_text: response.message(Body(response_text)) response = HttpResponse(str(response), content_type='application/xml') return response
def test_nested_body(self): b = Body('Hello World') r = MessagingResponse() r.append(b) assert_equal( self.strip(r), '<?xml version="1.0" encoding="UTF-8"?><Response><Body>Hello World</Body></Response>' )
def text_mixed(self): r = MessagingResponse() r.append('before') r.append(Body('Content')) r.append('after') assert_equal( self.strip(r), '<?xml version="1.0" encoding="UTF-8"?><Response>before<Body>Content</Body>after</Response>' )
def test_nested_body_media(self): b = Body('Hello World') m = Media('hey.jpg') r = MessagingResponse() r.append(b) r.append(m) assert_equal( self.strip(r), '<?xml version="1.0" encoding="UTF-8"?><Response><Body>Hello World</Body><Media>hey.jpg</Media></Response>' )
def create_sms(msg): response = MessagingResponse() message = Message() message.append(Body("\n" + msg)) print(msg) return str(response.append(message))