API Usage ######### 1. Start the backend server with ``flask run``. 2. Access the endpoints by calling them with the appropriate endpoints API Description =============== The backend facilitates communication with the Google Maps API as well as handling all storage and replication of user-generated content (chatrooms, messages, etc.) Model Documentation ====================== Mandates input at endpoints, raises error if these structures are not followed. ``CreateAttachment`` ``file_url`` - Mandatory string ``UpdateAttachment`` ``file_url`` - Optional string ``CreateChatroom`` ``chatroom_type`` - Mandatory string ``chatroom_name`` - Mandatory string ``coords_bottom_right`` - Optional string ``coords_top_left`` - Optional string ``UpdateChatroom`` ``chatroom_name`` - Optional string ``CreateMessage`` ``sender_id`` - Mandatory string ``content`` - Mandatory string ``UpdateMessage`` ``sender_id`` - Mandatory string ``content`` - Mandatory String ``Login`` ``username`` - Mandatory string ``password`` - Mandatory string ``DMRequest`` ``sender_id`` - Mandatory String ``recipient_id`` - Mandatory String ``FriendRequest`` ``sender_id`` - Mandatory String ``receiver_id`` - Mandatory String ``MentionCreate`` ``mentioned_user`` - Mandatory string ``ReportCreate`` ``sender_id`` - Mandatory String ``report_type`` - Mandatory string ``content`` - Mandatory String ``CreateUser`` ``username`` - Mandatory String ``password`` - Mandatory String ``UpdateUser`` ``username`` - Optional string ``password_hash`` - Optional string ``avatar_url`` - Optional string ``bio`` - Optional string ``account_status`` - Optional string ``age_verified`` - Optional boolean ``show_online_status`` - Optional boolean ``notifications_enabled`` - Optional boolean Endpoint Documentation ====================== Attachments ----------- ``/attachments/chatroom//`` GET - get all attachments for message POST - add attachment to message, takes json "file_url":string as args ``/attachments/chatroom///`` GET - get attachment on message PUT - edit attachment, takes JSON "file_url":string as args DELETE - delete attachment Auth ---- ``/auth/login`` POST - check if valid login, takes json "username":string,"password":string as args Blocks ------ ``/blocks/`` GET - List of users you blocked POST - block someone, takes json "blocked_id":uuid as args ``/blocks//`` DELETE - Unblock user ``/blocks/is_blocked//`` GET - check block status, one way Chatrooms --------- ``/chatrooms/`` GET - Get ALL CHATROOMS POST - Create chatroom, takes json "chatroom_type":string,"chatroom_name":string as args ``/chatrooms/`` GET - Get chatroom PUT - edit chatroom parameters, takes json "chatroom_name":string as args ``/chatrooms//memberships`` GET - get all members of chatroom ``/chatrooms/join`` POST - join chatroom, takes json "user_id":uuid,"chatroom_id":uuid as args ``/chatrooms/leave`` POST - remove user from chatroom, takes json "user_id":uuid,"chatroom_id":uuid as args ``/chatrooms/create`` POST - Create chatroom, takes json "user_id":uuid,"name":string,"description":string, "chatroom_type":string,"members":list,"lat":float,"lng":float as args Easier to memorise endpoint for POSTing /chatrooms ``/chatrooms/user/`` GET - For every chatroom chatrooms user belongs to, get its details, their last message there and its timestamp ``/chatrooms//add_member`` POST - add member to chatroom, takes json "user_id":uuid as args ``/chatrooms//add_member`` POST - remove member from chatroom, takes json "user_id":uuid as args ``/chatrooms//info`` GET - get all metadata for chatroom DM Requests ----------- ``/dm_requests/send`` POST - Sends DM Request, takes json "sender_id":uuid,"recipient_id":uuid as args ``/dm_requests/incoming/`` GET - Get incoming DM requests for user ``/dm_requests/accept/`` POST - Accept DM request with ID ``/dm_requests/decline/`` POST - Decline DM request with ID Friend Requests --------------- ``/friend_requests/send`` POST - Send friend request, takes json "sender_id":uuid,"receiver_id":uuid as args ``/friend_requests//incoming`` GET - Get list of incoming friend requests for user ``/friend_requests//outgoing`` GET - get all outgoing, currently pending friend requests from user ``/friend_requests//accept`` POST - Accept incoming friend request, send notification of acceptance, create DM chatroom if doesn't exist ``/friend_requests//decline`` POST - DECLINE incoming friend request ``/friend_requests//cancel`` POST - cancel outgoing friend request ``/friend_requests/status//`` GET - Check status of outgoing friend request Map --- ``/map/login`` GET - get map image at coordinates and zoom level, effectively an interface to map api, takes lat=float,lng=float,zoom=int as POST args ``/map/chatrooms/nearby`` GET - Get list of locational chatrooms, takes lat=float,lng=float,radius=int as POST args Mentions -------- ``/mentions/chatroom//`` GET - get mentions included in message POST - add mention to message, takes json "mentioned_user":uuid as args Messages -------- ``/messages/chatroom/`` GET - get all messages in chatroom POST - add message to chatroom, takes json "sender_id":uuid, "content":string as args ``/messages/chatroom//`` PUT - edit message at ID, takes json "content":string as args DELETE - delete message at ID Notifications ------------- ``/notifications/`` GET - GET NOTIFICATIONS FOR USER ``/notifications/mark_read/`` POST - Mark notification as read Reports ------- ``/reports//reports`` GET - get all reports for message POST - report message, takes json "sender_id":uuid,"report_type":string,"content":string as args ``/reports//`` GET - get individual report for message, display info DELETE - remove report from message Users ----- ``/users`` GET - get all users POST - add user to database, takes in json "username":string,"password_hash":string as args ``/users/`` GET- Get all info about a user stored in the users table PUT - edit user info - takes json "field":data as args based on table described in function ``/users//memberships`` GET - get all chatroom_memberships for user POST - add user to chatroom - takes json "chatroom_id":uuid as args ``/users//friends`` GET - get all user friends ``/users//notifications_enabled`` GET - return whether or not notifications are enabled for user (setting endpoint) POST - enable/disable notifications for user - takes in json "enabled":bool as args ``/users//presence_visibility`` GET - return whether or not presence status is shown for user (setting endpoint) POST - enable/disable presence visibility setting - takes in json "visible":bool as args ``/users//presence/online`` POST - set user as online ``/users//presence/offline`` POST - set user as offline