Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add:Add Full CRUD Routes and Consistent API Responses #624

Open
4 tasks
nyainda opened this issue Feb 27, 2025 · 5 comments
Open
4 tasks

Add:Add Full CRUD Routes and Consistent API Responses #624

nyainda opened this issue Feb 27, 2025 · 5 comments

Comments

@nyainda
Copy link

nyainda commented Feb 27, 2025

Description

Add missing CRUD routes (index and update) to the testimonial system and implement consistent API response formatting.

Acceptance Criteria

  • Routes added:
    • GET /testimonials (index)
    • GET /testimonials/{id} (show)
    • POST /testimonials (store)
    • PUT /testimonials/{id} (update)
    • DELETE /testimonials/{id} (destroy)
  • API responses use ApiResponse trait for consistency
  • All endpoints return appropriate status codes (200, 201, 404, etc.)
  • Tests cover all CRUD operations

Purpose

Completes the testimonial API functionality and ensures a uniform response structure for better client integration.

Requirements

  • Laravel routing in api.php
  • TestimonialController updates
  • ApiResponse trait implementation
  • Postman for testing

Expected Outcome

Full CRUD operations are available, with responses like { "status": "success", "data": {...} }. Screenshots:

  • GET /testimonials: testmony2
  • POST /testimonials: tesmony3
  • PUT /testimonials/{id}: tesmony4

Additional Context

  • Builds on existing store/show/destroy functionality
  • Enhances API usability
@bhimbho
Copy link
Contributor

bhimbho commented Feb 27, 2025

testimonial show, destroy and store already exists. Is there a use case for index and update?
Image

@Ruthiejayjay
Copy link
Contributor

The screenshot you shared is from the testimonials, right? It's using the correct response, what would you like to update in the response?

@nyainda
Copy link
Author

nyainda commented Feb 28, 2025

the reason why i added the 2 but if you dont see any good reason i can remove them
Update Method - This is critical because:

.Users may make spelling mistakes in their testimonials
.Users might want to revise their testimonial content after submission
.Content might need moderation or editing

Index Method - This would be useful for:

.Displaying all testimonials on a webpage
.Admin panels to review all testimonials
.Filtering or searching through testimonials

@nyainda
Copy link
Author

nyainda commented Feb 28, 2025

from the instruction we were to follow this format for response
The API responses should follow the structure below for uniformity (Refer to the docs)

{
"status": "string",
"status_code": number,
"message": "string",
"data": {}
}

here is the response format
{
"status": "success",
"status_code": 200,
"message": "Testimonial created successfully",
"data": {
"user_id": "9e517938-ed7e-48cf-8bbf-153855b10fe8",
"name": "Anonymous User",
"content": "I am extremely satisfied with the exceptional service provided by the company. Their response time and attention to detail exceeded my expectations!",
"id": "9e5179e5-be07-49a3-adb9-24e84ec1fd8b",
"updated_at": "2025-02-28T07:29:06.000000Z",
"created_at": "2025-02-28T07:29:06.000000Z"
}
}

@bhimbho
Copy link
Contributor

bhimbho commented Feb 28, 2025

@nyainda the instruction format looks exactly like what you have in your screenshot. you can proceed to working on the index and update provided there is a use case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants