Example #1
0
 def put(self, id=None):
     data = ApiContact.parser.parse_args()
     contact = Contact.find_by_id(data['id'])
     if contact is None:
         contact = Contact(data['name'], data['email'])
     else:
         contact.name = data['name']
         contact.email = data['email']
     contact.save_to_db()
     return contact.json()
Example #2
0
 def get(self, id=None):
     contact = Contact.find_by_id(self, id)
     if contact:
         return contact.json()
     return {'message' : 'Contact not found'}, 404
Example #3
0
 def delete(self, id):
     contact = Contact.find_by_id(id)
     if contact:
         contact.delete_from_db()