From 56b55b042b52a10bd4f61c829eb625271fc6bd6b Mon Sep 17 00:00:00 2001
From: Akif9748 <akif9748@gmail.com>
Date: Thu, 11 Aug 2022 01:11:07 +0300
Subject: [PATCH] API DOCS updated

---
 README.md               | 16 +++++-----------
 tests/get_msg.py        |  7 +++----
 tests/get_thread.py     |  6 +++---
 tests/get_user.py       |  2 +-
 tests/post_msg.py       | 17 +++--------------
 tests/post_msg_react.py | 17 +++++++++++++++++
 tests/post_thread.py    | 30 ++++++++----------------------
 util/APIDOCS.md         | 34 +++++++++-------------------------
 8 files changed, 49 insertions(+), 80 deletions(-)
 create mode 100644 tests/post_msg_react.py

diff --git a/README.md b/README.md
index 2c6e2df..1002c35 100644
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@ And, you can learn about API in `util/APIDOCS.md`.
 | Send | 🟢 | HIGH |
 | Delete | 🟢 | HIGH |
 | React | 🟢 | MEDIUM |
-| Edit | 🔴 | HIGH |
+| Edit | 🔴 | MEDIUM |
 
 ### Threads
 | To do | Is done? | Priority |
@@ -52,7 +52,7 @@ And, you can learn about API in `util/APIDOCS.md`.
 | Ratelimit | 🟢 | HIGH |
 | Create | 🟢 | HIGH |
 | Delete | 🟢 | HIGH |
-| Edit | 🔴 | HIGH |
+| Edit | 🔴 | MEDIUM |
 
 ### API
 | To do | Is done? | Priority |
@@ -61,14 +61,8 @@ And, you can learn about API in `util/APIDOCS.md`.
 | Send message | 🟢 | MEDIUM |
 | Create thread | 🟢 | MEDIUM |
 | Get info about thread | 🟢 | MEDIUM |
-<<<<<<< HEAD
-| Delete message & thread | 🔴 | MEDIUM |
-| Edit message & thread | 🔴 | MEDIUM |
-
-=======
-| Delete message | 🔴 | MEDIUM |
-| React | 🟢 | MEDIUM |
->>>>>>> 9f10a32b7ce05cbb81acacb8277b68c25d4baa34
+| Delete message & thread | 🔴 | HIGH |
+| Edit message & thread | 🔴 | HIGH |
 
 ### Other
 | To do | Is done? | Priority |
@@ -77,7 +71,7 @@ And, you can learn about API in `util/APIDOCS.md`.
 | Multi-theme support | 🔴 | LOW |
 | Search | 🔴 | MEDIUM |
 | Better view | 🟢 | MEDIUM |
-| Sending message etc. will use fetch API | 🔴 | HIGH |
+| Sending message etc. will use fetch API | 🟡 | HIGH |
 
 ## Screenshot
 ![akf-forum](https://user-images.githubusercontent.com/70021050/160255959-ef216cba-1348-4d4b-9347-fe67e21348e7.png)
diff --git a/tests/get_msg.py b/tests/get_msg.py
index a4e6177..43aaea3 100644
--- a/tests/get_msg.py
+++ b/tests/get_msg.py
@@ -14,7 +14,6 @@ print(r.json())
 example_response = {
     'status': 200,
     'result': {
-        'authorID': 0,
         'content': 'a',
         'author': {
             'name': 'Akif9748',
@@ -22,14 +21,14 @@ example_response = {
             'time': 1649189944864,
             'admin': False,
             'deleted': False,
-            'id': 0
+            'id': "0"
         },
         'time': 1649189950166,
-        'threadID': 0,
+        'threadID': "0",
         'deleted': False,
         'edited': False,
         # Reactions: {userid: isLike (Bool)}
         'react': {'0': True},
-        'id': 0
+        'id': "0"
     }
 }
diff --git a/tests/get_thread.py b/tests/get_thread.py
index 507d354..0e8fab9 100644
--- a/tests/get_thread.py
+++ b/tests/get_thread.py
@@ -20,12 +20,12 @@ example_response = {
             "time": 1647895891332,
             "admin": False,
             "deleted": False,
-            "id": 0
+            "id": "0"
         },
         "title": "First Thread",
-        "messages": [0, 1, 2, 3],
+        "messages": ["0", "1", "2", "3"],
         "time": 1647895907054,
         "deleted": False,
-        "id": 0
+        "id": "0"
     }
 }
diff --git a/tests/get_user.py b/tests/get_user.py
index 42148cc..0285972 100644
--- a/tests/get_user.py
+++ b/tests/get_user.py
@@ -19,6 +19,6 @@ example_response = {
         'time': 1647895891332,
         'admin': True,
         'deleted': False,
-        'id': 0
+        'id': "0"
     }
 }
diff --git a/tests/post_msg.py b/tests/post_msg.py
index f2e9c3a..bfd4c70 100644
--- a/tests/post_msg.py
+++ b/tests/post_msg.py
@@ -27,24 +27,13 @@ example_response = {
             'time': 1649009854217,
             'admin': False,
             'deleted': False,
-            'id': 2
+            'id': "2"
         },
         'time': 1649010863471,
-        'thread':  {
-            'author': {
-                'name': 'Akif9748',
-                'avatar': 'https://www.technopat.net/sosyal/data/avatars/o/298/298223.jpg?1644694020',
-                'time': 1647895891332, 'admin': True, 'deleted': False, 'id': 0
-            },
-            'title': 'API TEST',
-            'messages': [4, 6],
-            'time': 1649010834064,
-            'deleted': False,
-            'id': 1
-        },
+        'threadID': "1",
         'deleted': False,
         'edited': False,
         'react': {},
-        'id': 6
+        'id': "6"
     }
 }
diff --git a/tests/post_msg_react.py b/tests/post_msg_react.py
new file mode 100644
index 0000000..7457a43
--- /dev/null
+++ b/tests/post_msg_react.py
@@ -0,0 +1,17 @@
+import requests
+
+# Headers for login to Akf-forum
+headers = {
+    "username": "testUser",
+    "password": "testPassword"
+}
+
+r = requests.post("http://localhost:3000/api/messages/0/react/like",
+                  headers=headers)
+
+print(r.json())
+
+example_response = {
+    'status': 200,
+    'result': 1 # Number of likes
+}
diff --git a/tests/post_thread.py b/tests/post_thread.py
index 5c02203..9fdf240 100644
--- a/tests/post_thread.py
+++ b/tests/post_thread.py
@@ -20,31 +20,17 @@ print(r.json())
 example_response = {
     'status': 200,
     'result': {
-        'content': 'This message sent via API',
         'author': {
-            'name': 'testUser',
-            'avatar': '',
-            'time': 1649009854217,
-            'admin': False,
-            'deleted': False,
-            'id': 2
-        },
-        'time': 1649010863471,
-        'thread':  {
-            'author': {
-                'name': 'Akif9748',
-                'avatar': 'https://www.technopat.net/sosyal/data/avatars/o/298/298223.jpg?1644694020',
-                'time': 1647895891332, 'admin': True, 'deleted': False, 'id': 0
-            },
-            'title': 'API TEST',
-            'messages': [4, 6],
-            'time': 1649010834064,
-            'deleted': False,
-            'id': 1
+            'name': 'Akif9748',
+            'avatar': 'https://www.technopat.net/sosyal/data/avatars/o/298/298223.jpg?1644694020',
+            'time': 1647895891332, 'admin': True, 'deleted': False, 'id': "0"
         },
+        'title': 'API TEST',
+        'messages': ["4", "6"],
+        'time': 1649010834064,
         'deleted': False,
         'edited': False,
-        'react': {},
-        'id': 6
+        'id': "1",
+
     }
 }
diff --git a/util/APIDOCS.md b/util/APIDOCS.md
index 247e516..814a463 100644
--- a/util/APIDOCS.md
+++ b/util/APIDOCS.md
@@ -16,15 +16,12 @@ You need this headers for send request to API:
 
 ## How to request?
 
-### Request type:
-  `GET /api/action` 
-
-### "action" types:
-- GET `messages/:id`
-- GET `users/:id` 
-- GET `threads/:id`  
-- POST `messages` 
-
+### Request types:
+- GET `/api/messages/:id`
+- GET `/api/users/:id` 
+- GET `/api/threads/:id`  
+- POST `/api/messages` 
+- POST `/api/messages/:id/react/:type` 
 
 ### Example request:
 ```GET /api/message/1```
@@ -40,28 +37,15 @@ You need this headers for send request to API:
         "deleted": false,
         "edited": false,
         "react": {},
-        "id": 1,
+        "id": "1",
         "author": {
             "name": "ForumcuCocuk",
             "avatar": "/images/guest.png",
             "time": 1647177723873,
             "admin": true,
-            "id": 1
+            "id": "1"
         },
-        "thread": {
-            "author": {
-                "name": "Akif9748",
-                "avatar": "/images/guest.png",
-                "time": 1647177705200,
-                "admin": true,
-                "id": 0
-            },
-            "title": "First Thread",
-            "messages": [0, 1], 
-            "time": 1647178870047,
-            "deleted": false,
-            "id": 0
-        }   
+        "threadID":"0" 
     }
 }