def make_xml(self, data, user_id): """ Transform the data provided to an XML fragment @param userid: the USPS API user id @param data: the data to serialize and send to USPS @return: an XML fragment representing data """ for data_dict in data: data_xml = dicttoxml(data_dict, self.SERVICE_NAME+'Request', self.PARAMETERS) data_xml.attrib['USERID'] = user_id return data_xml
def make_xml(self, data, user_id, password=None): """ Transform the data provided to an XML fragment @param userid: the USPS API user id @param data: the data to serialize and send to USPS @return: an XML fragment representing data """ root = ET.Element(self.SERVICE_NAME+'Request') root.attrib['USERID'] = user_id root.attrib['PASSWORD'] = password index = 0 for data_dict in data: data_xml = dicttoxml(data_dict, self.CHILD_XML_NAME, self.PARAMETERS) data_xml.attrib['ID'] = str(index) root.append(data_xml) index += 1 return root
def make_xml(self, data, user_id): """ Transform the data provided to an XML fragment @param userid: the USPS API user id @param data: the data to serialize and send to USPS @return: an XML fragment representing data """ root = ET.Element(self.SERVICE_NAME + 'Request') root.attrib['USERID'] = user_id index = 0 for data_dict in data: data_xml = dicttoxml(data_dict, self.CHILD_XML_NAME, self.PARAMETERS) data_xml.attrib['ID'] = str(index) root.append(data_xml) index += 1 return root