fsheikh / sample_code

Some sample code snippets
1 stars 1 forks source link

REST API design #5

Open fsheikh opened 1 month ago

fsheikh commented 1 month ago

REST API with json request and response structure should be documented showing covering at least following use-cases

root-endpoint: www.deurdu.de End point Http Request Description JSON
/en GET all blogs available in English TBA
/ur GET all blogs available in Urdu TBA
/de GET all blogs available in German TBA
/categories/:category GET all blogs available category TBA
/users/:category/:user GET all blogs available in category filtered by user TBA
/users/:category/:user/post POST post content category filtered by user TBA
/about GET Shows About-us information TBA
/contact GET Shows a form to send message TBA
MuhammadTaha01 commented 1 month ago

Flowchart for (User posts a blogs with multimedia content)


flowchart TD
    A[User fills in blog details and uploads multimedia content] --> B[User clicks 'Post Blog' button]
    B --> C{Is the submission valid?}
    C -->|Yes| D[Server processes the blog and multimedia content]
    D --> E{Was the blog posted successfully?}
    E -->|Yes| F[Blog is posted and visible on the 'View Blogs' page]
    E -->|No| G[Failure: Pop-up message displayed to user informing about the issue]
    C -->|No| H[Failure: Pop-up message displayed to user indicating invalid input]
MuhammadTaha01 commented 1 month ago

Flowchart for (User retrieves the blog posts from selected language)


flowchart TD
    A[User selects a language filter on 'View Blogs' page] --> B[API request sent to retrieve blogs in the selected language]
    B --> C{Are blogs available in the selected language?}
    C -->|Yes| D[Display all blogs in the selected language]
    C -->|No| E[Display message: 'No blogs available in this language']
MuhammadTaha01 commented 1 month ago

Flowchart for (User retrieves the blog posts from selected category)


flowchart TD
    A[User selects a category from the category list] --> B[API request sent to retrieve blogs in the selected category]
    B --> C{Are blogs available in the selected category?}
    C -->|Yes| D[Display all blogs in the selected category]
    C -->|No| E[Display message: 'No blogs available in this category']
MuhammadTaha01 commented 1 month ago

Flowchart for (user clicks on contact info of the author's name)


flowchart TD
    A[User clicks on the author's name or 'Contact Info' link] --> B[API request sent to retrieve author's contact information]
    B --> C{Is the author’s contact information available?}
    C -->|Yes| D[Display the author's contact information]
    C -->|No| E[Display message: 'Contact information not available']
MuhammadTaha01 commented 1 month ago

1) All blogs to be retrieved in English

{ "language": "en", "blogs": [ { "id": 1, "title": "First Blog in English", "content": "This is the content of the first blog in English.", "author": "Author Name", "category": "Technology", "datePublished": "2024-08-20" }, { "id": 2, "title": "Second Blog in English", "content": "This is the content of the second blog in English.", "author": "Author Name", "category": "Science", "datePublished": "2024-08-19" } ] }


2) All blogs to be retrieved in Urdu

{ "language": "ur", "blogs": [ { "id": 1, "title": "پہلا بلاگ", "content": "یہ پہلا اردو بلاگ ہے", "author": "مصنف کا نام", "category": "ٹیکنالوجی", "datePublished": "2024-08-20" } // Add more blogs as needed ] }


3) All blogs to be retrieved in German

{ "language": "de", "blogs": [ { "id": 1, "title": "Erster Blog auf Deutsch", "content": "Dies ist der erste Blog auf Deutsch.", "author": "Autor Name", "category": "Technologie", "datePublished": "2024-08-20" } // Add more blogs as needed ] }


4) All blogs to be retrieved in [Selected Category By User]

{ "category": "Technology", "blogs": [ { "id": 1, "title": "Tech Blog 1", "content": "Content for tech blog 1.", "author": "Author Name", "language": "en", "datePublished": "2024-08-20" } // Add more blogs in the same category ] }


5) All blogs to be retrieved in [Selected Category By User & By Selective User]

{ "category": "Technology", "user": "Author Name", "blogs": [ { "id": 1, "title": "Tech Blog by Author", "content": "Content for tech blog by Author Name.", "language": "en", "datePublished": "2024-08-20" } // Add more blogs by the user in the specified category ] }


6) Post content in [Selected Category By User & By Selective User]

Request: { "title": "New Blog Title", "content": "This is the content of the new blog.", "language": "en", "datePublished": "2024-08-20" } Response: { "message": "Blog posted successfully", "blogId": 3, "category": "Technology", "user": "Author Name" }


7) Shows About Us Information

{ "about": { "title": "About Us", "content": "We are a blogging platform dedicated to providing the best content in multiple languages.", "founders": ["Founder 1", "Founder 2"], "established": "2023" } }


8) Shows a form to send message

{ "contactForm": { "fields": [ { "name": "name", "type": "text", "placeholder": "Your Name" }, { "name": "email", "type": "email", "placeholder": "Your Email" }, { "name": "message", "type": "textarea", "placeholder": "Your Message" } ] } }