Repository: fossasia/open-event-server

Issue:
Add API blueprints of Multiple Email support for users
**Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

Add API blueprints of Multiple Email support for users

**Describe the solution you'd like**
<!-- A clear and concise description of what you want to happen. -->

**Describe alternatives you've considered**
<!-- A clear and concise description of any alternative solutions or features you've considered. -->

**Additional context**
<!-- Add any other context or screenshots about the feature request here. -->
**Wanna work on this issue**


Discussion:

Resolving patch:
diff --git a/app/factories/user_email.py b/app/factories/user_email.py
new file mode 100644
--- /dev/null
+++ b/app/factories/user_email.py
@@ -0,0 +1,16 @@
+import factory
+
+import app.factories.common as common
+from app.factories.user import UserFactory
+from app.models.user_email import db, UserEmail
+
+
+class UserEmailFactory(factory.alchemy.SQLAlchemyModelFactory):
+    class Meta:
+        model = UserEmail
+        sqlalchemy_session = db.session
+
+    user = factory.RelatedFactory(UserFactory)
+    user_id = 1
+    email_address = common.email_
+    type = common.string_


Test patch:
diff --git a/tests/hook_main.py b/tests/hook_main.py
--- a/tests/hook_main.py
+++ b/tests/hook_main.py
@@ -54,6 +54,7 @@
 from app.factories.mail import MailFactory
 from app.factories.order import OrderFactory
 from app.factories.faq_type import FaqTypeFactory
+from app.factories.user_email import UserEmailFactory
 from app.factories.feedback import FeedbackFactory
 from app.factories.service import ServiceFactory
 from app.factories.message_setting import MessageSettingsFactory
@@ -2165,6 +2166,88 @@ def email_notification_delete(transaction):
         db.session.commit()
 
 
+# ------------------------- User Emails -------------------------
+@hooks.before("User Emails > User Email Admin Collection > List All User Emails")
+def user_email_get_admin_list(transaction):
+    """
+    GET /admin/user-emails
+    :param transaction:
+    :return:
+    """
+    with stash['app'].app_context():
+        user_email = UserEmailFactory()
+        db.session.add(user_email)
+        db.session.commit()
+
+
+@hooks.before("User Emails > User Email Collection > List All User Emails")
+def user_email_get_list(transaction):
+    """
+    GET /users/2/alternate-emails
+    :param transaction:
+    :return:
+    """
+    with stash['app'].app_context():
+        user_email = UserEmailFactory()
+        db.session.add(user_email)
+        db.session.commit()
+
+
+@hooks.before("User Emails > User Email Collection Post > Create User Email")
+def user_email_post(transaction):
+    """
+    POST /user-emails
+    :param transaction:
+    :return:
+    """
+    with stash['app'].app_context():
+        user_email = UserEmailFactory()
+        # user = UserFactory()
+        # db.session.add(user)
+        db.session.add(user_email)
+        db.session.commit()
+
+
+@hooks.before("User Emails > User Email Detail > User Email Detail")
+def user_email_get_detail(transaction):
+    """
+    GET /user-emails/1
+    :param transaction:
+    :return:
+    """
+    with stash['app'].app_context():
+        user_email = UserEmailFactory()
+        db.session.add(user_email)
+        db.session.commit()
+
+
+@hooks.before("User Emails > User Email Detail > Update User Email")
+def user_email_patch(transaction):
+    """
+    PATCH /user-emails/1
+    :param transaction:
+    :return:
+    """
+    with stash['app'].app_context():
+        user_email = UserEmailFactory()
+        db.session.add(user_email)
+        db.session.commit()
+
+
+@hooks.before("User Emails > User Email Detail > Delete User Email")
+def user_email_delete(transaction):
+    """
+    DELETE /user-emails/1
+    :param transaction:
+    :return:
+    """
+    with stash['app'].app_context():
+        user_email = UserEmailFactory()
+        db.session.add(user_email)
+        db.session.commit()
+
+
+
 # ------------------------- Image Size -------------------------
 @hooks.before("Image Size > Event Image Size Details > Get Event Image Size Details")
 def event_image_size_get_detail(transaction):