Implemented upsert_contact method