def build(self): phonebook = Phonebook() for record in self.json_data: contact = Contact(record['name'], record['surname']) phonebook.add_contact(contact) for number in record['numbers']: contact.add_new_number(number['phone_number'], number['phone_type']) return phonebook
def _build_contact(self): contact = Contact(self.name, self.surname) contact.add_new_number(self.phone_number, self.phone_type) return True, contact