Ejemplo n.º 1
0
 def send(self, dictionary):
     # reroute the remote calls to local calls for testing
     api_request = dict_to_xml(dictionary, root=Element("sms_api"))
     log.msg("Sending XML: %s" % tostring(api_request))
     
     protocol = yield self.creator.connectTCP(self.hostname, self.port)
     api_response = yield protocol.send_xml(api_request)
     response = api_response_to_dict(api_response)
     log.msg("Received Dict: %s" % response)
     if response.get('error_type'):
         raise ApiException(response['error_type'], api_response)
     log.msg('Returning: %s' % response)
     returnValue(response)
Ejemplo n.º 2
0
 def send(self, dictionary):
     # reroute the remote calls to local calls for testing
     api_action = dictionary['api_action']
     sent_xml = dict_to_xml(dictionary, Element("sms_api"))
     log.msg("Sending XML: %s" % tostring(sent_xml))
     received_xml = yield self.dispatcher.dispatch(api_action, sent_xml)
     xml = fromstring(received_xml)
     log.msg("Received XML: %s" % tostring(xml))
     sms_api, response = xml_to_dict(xml)
     log.msg("Received Dict: %s" % response)
     # if at any point, we get this error something went wrong
     if response.get('error_type'):
         raise ApiException(response['error_type'], tostring(xml))
     log.msg('Returning: %s' % response)
     returnValue(response)